Example #1
0
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;
}
Example #2
0
/*------------------------------------------------------------
 *   �ѵ�ɬ��ë���继�������ƻ�֧�£�  �꼰�ֳ��ƥ���£�
 *------------------------------------------------------------*/
static int TITLE_getConfigOneLine( FILE *fp, char *line, int linelen)
{
	char    buf[1024];
	int     startflg = FALSE;
	int     linenum=0;
	line[0] = '\0';
	
	while( fgets( buf, sizeof( buf ), fp )){
		linenum ++;
		if( buf[0] == '#' )continue;        /* comment */
		if( buf[0] == '\n' )continue;       /* none    */
		/*  ���������    */
		/*  ���� tab ë " " ��  �徧����    */
		replaceString( buf, '\t' , ' ' );
		/* ��ʸ�������� */
		deleteCharFromString( buf, " ");

		if( buf[0] == '{' ) {
			if( startflg == TRUE ) {
				print( "titleconfig:����û�йرա�{��ȴ������: %d \n",linenum);
				/* } */
				return -1;
			}
			startflg = TRUE;
		}
		else if( buf[0] == '}' ) {
			if( startflg == FALSE) {
				print( "titleconfig:����û�йرա�{��ȴ������: %d \n",linenum);
				/* } */
				return -1;
			}
			return 1;
		}
		else {
			/* "{"ƥ�ȱ�����Ȼ������� }*/
			if( startflg == TRUE ) {
				if( strlen( line) != 0 ) {
					if( line[strlen(line) -1] != ',' ) {
						strcatsafe( line, linelen, ",");
					}
				}
				/* �������继������*/
				chompex( buf );
				strcatsafe( line,linelen,  buf);
			}
			/*   ���ֻ�"{"ƥ��Ԫ���Ȼ�ئ�������������������ƥ߯�� }*/
			else {
				chompex( buf );
				strcatsafe( line,linelen,  buf);
				return 1;
			}
		}
	}
	/* �����������ɵ��Ƿ�EOF   ѱ��Ԫ��ئ��������   */
	return 0;
}
Example #3
0
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);
	}
}
Example #4
0
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);
}