Example #1
0
main()
{
    char out[100];
    int a,b,c;
    

    easyGetTokenFromString( data ,1, out , sizeof(out) );
    a = atoi( out );
    printf("hoge:'%s'\n" , out );
    easyGetTokenFromString( data , 2, out , sizeof(out) );
    b = atoi(out);
    printf("hoge:'%s'\n" , out );
    easyGetTokenFromString( data , 3, out , sizeof(out) );
    c=atoi( out);
    printf("hoge:'%s'\n" , out );
    printf( "%d %d %d\n" , a ,b,c );
}
Example #2
0
static int readConfig( char *path )
{
    char buf[2048];
    FILE *fp;

    fp = fopen( path , "r" );
    if( fp == NULL ){ return -2; }

    while( fgets( buf , sizeof( buf ) , fp )){
        char command[128];
        char param[128];
        chop(buf);
        
        easyGetTokenFromString( buf , 1 , command , sizeof( command ));
        easyGetTokenFromString( buf , 2 , param , sizeof( param ));

        if( strcmp( command , "port" ) == 0 ){
            port = atoi( param );
        		log( "¶Ë¿Ú:%d\n",port );
        } else if( strcmp( command , "logdir" ) == 0 ){
            snprintf( logdir , sizeof( logdir) , param );
            log( "ÈÕ־Ŀ¼:%s\n",logdir );
        } else if( strcmp( command , "chardir" ) == 0 ){
            snprintf( chardir , sizeof( chardir) , param );
            log( "µµ°¸Ä¿Â¼:%s\n",chardir );
        } else if( strcmp( command , "charbakdir" ) == 0 ){
            snprintf( charbakdir , sizeof( charbakdir) , param );
            log( "µµ°¸±¸·ÝĿ¼:%s\n",charbakdir );
#ifdef _SLEEP_CHAR
						snprintf( sleepchardir , sizeof( sleepchardir), "%s_sleep", chardir);
						log( "˯ÃßĿ¼:%s\n",sleepchardir );
#endif
        } else if( strcmp( command , "pass" ) == 0 ){
        		snprintf( svpass , sizeof( svpass ) , param);
            log( "ÃÜÂë:%s\n",param );
        } else if( strcmp( command , "dbdir" ) == 0 ){
            snprintf( dbdir , sizeof( dbdir) , param );    
            log( "Êý¾ÝĿ¼:%s\n",dbdir );        
        } else if( strcmp( command, "rotate_interval" ) == 0 ){
            log_rotate_interval = atoi( param );
            log( "ÈÕ־ѭ»·¼ä¸ô:%d\n",log_rotate_interval ); 
        } else if( strcmp( command, "maildir" ) == 0 ){
            snprintf( maildir, sizeof( maildir ), param );
            log( "ÓʼþĿ¼:%s\n",maildir );
#ifdef	_FAMILY
        // CoolFish: Family 2001/5/9
        } else if( strcmp( command, "familydir" ) == 0 ){
            snprintf( familydir, sizeof( familydir ), param );
            log( "¼Ò×åĿ¼:%s\n",familydir );
        } else if( strcmp( command, "fmpointdir" ) == 0 ){
            snprintf( fmpointdir, sizeof( fmpointdir ), param );
            log( "ׯ԰±íÁÐ:%s\n",fmpointdir );
        } else if( strcmp( command, "fmsmemodir" ) == 0 ){
            snprintf( fmsmemodir, sizeof( fmsmemodir ), param );
            log( "¼Ò×屸·Ý:%s\n",fmsmemodir );
#endif
			  } else if( strcmp( command , "Total_Charlist" ) == 0 ){
        	Total_Charlist = atoi( param );
        	log( "¸üÐÂÈËÎïµãÊý¼ä¸ô:%dÃë\n",Total_Charlist );
        } else if( strcmp( command , "Expired_mail" ) == 0 ){
        	Expired_mail = atoi( param );
        	log( "¸üйýÆÚÓʼþ¼ä¸ô:%dÃë\n",Expired_mail );
        } else if( strcmp( command , "Del_Family_or_Member" ) == 0 ){
        	Del_Family_or_Member = atoi( param );
        	log( "ɾ³ý¼Ò×å³ÉÔ±¼ä¸ô:%dÃë\n",Del_Family_or_Member );
        } else if( strcmp( command , "Write_Family" ) == 0 ){
        	Write_Family = atoi( param );
        	log( "¸üмÒ×åÐÅÏ¢¼ä¸ô:%dÃë\n",Write_Family );
				}
    }

    fclose(fp);
    return 0;
}
Example #3
0
static void workerMainLoop( void )
{
    char linebuf[4096];
	int i_flag;//Arminitus && ttom 12/15
	time_t retime;

#ifndef _FIX_WORKS
	struct sockaddr_in sin;
	int addrlen = sizeof( sin );
	FILE *fp;
	int newsockfd  ;
    while(1){
        fd_set  rfds;
        struct timeval t;
        t.tv_sec = timeout;
        t.tv_usec = 0;
        FD_ZERO( &rfds );
        FD_SET( mainsockfd , &rfds );
        select( 1024 , &rfds , (fd_set*) NULL , (fd_set*)NULL , &t );
        if( FD_ISSET( mainsockfd , &rfds ) ){
            newsockfd = accept( mainsockfd , (struct sockaddr*) &sin , &addrlen );
            if( newsockfd < 0 ){
                fprintf( stderr,"accept error! \n");
            } else {
                memcpy(&myIP, &sin.sin_addr, sizeof(long));
                fprintf( stderr,"accepted. myIP=%ld\n", myIP );
            }
            break;
        } else {
            fprintf(stderr, "accept timed out." );
            exit(0);
        }
    }
    close(mainsockfd);
    {
        int flag = 1;
        int result = setsockopt( newsockfd, IPPROTO_TCP, TCP_NODELAY,
                                 (char*) &flag, sizeof(int));
        if( result != 0 ){
            fprintf( stderr , "nodelay error!\n" );
        }
    }
    fp = fdopen( newsockfd , "r+");
    if( fp == NULL ){
        fprintf( stderr,"fdopen error.abort" );
        return ;
    }
#endif

	//確認CS可連線
	if( checkCSconnect() == -1 ) return;
#ifdef _FIX_WORKS
	if( !LoginToAC() )	//login to ac
		return;
	retime = time( NULL);
	while( WORK_TYPE!=-1)	{
#else
while( fgets( linebuf,sizeof(linebuf), fp)){
#endif
    	// Spock 2000/10/31
        char id[104] ,pas[1024] , flag[8] , process[16];
        // Spock end
        int knret;
		char deadline[100] = "0"; // _TIMEOUTKICK
		usleep(10*1000);

#ifdef _FIX_WORKS
		if( (WORK_TYPE = Ac_message_accept( linebuf, sizeof( linebuf))) <= 0 )
			continue;
		retime = time( NULL);
#endif
		memset( id, 0, sizeof( id));
		memset( process, 0, sizeof( process));
		memset( flag, 0, sizeof( flag));

        /* chop */
        linebuf[strlen(linebuf)-1]=0;
        /* kill-\r */
        remove_r( linebuf );

        easyGetTokenFromString( linebuf , 1 , id , sizeof( id ));
        easyGetTokenFromString( linebuf , 2 , pas , sizeof( pas ));
        // Nuke +1
        easyGetTokenFromString( linebuf , 3 , flag, sizeof(flag));
        // Spock 2000/10/31
       	easyGetTokenFromString( linebuf , 4 , process , sizeof(process) );
        // Spock end
        
        // Nuke
        i_flag=0;          //Arminius && ttom
        i_flag=atoi(flag); //Arminius && ttom
        if((!process)||(!*process)){
           knret=-7;
        }else{
       		switch (i_flag) {  //Arminius && ttom

#ifdef _FIX_MESSAGE                // WON ADD 修改封包內容	

#ifdef _TIMEOUTKICK

			case  1: // List
#ifdef _AP_CHECK_3_TIMES           // WON ADD 減少認證次數
				knret = 0;
#else
				knret = doKN( id, pas, flag, "", deadline);
#endif
				break;
       		case  4: // Delete
				knret = doKN( id , pas , flag, "" , deadline);
				break;
			case  2: // Load
				knret = doKN( id , pas , flag, "" , deadline);
				break;
			case  3: // Save
				knret = doKN( id , pas, flag, "" , deadline);
				break;
			case  5: // recheck WGS
				knret = doKN( id , pas , flag, "" , deadline);
				break;

#else

			case  1: // List
#ifdef _AP_CHECK_3_TIMES           // WON ADD 減少認證次數
				knret = 0;
#else
				knret = doKN( id, pas, flag, "");
#endif
				break;
       		case  4: // Delete
				knret = doKN( id , pas , flag, "" );
				break;
			case  2: // Load
				knret = doKN( id , pas , flag, "" );
				break;
			case  3: // Save
					knret = doKN( id , pas, flag, "" );
				break;

#endif

#else


       		case  1: // List
				knret = doKN( id, pas, flag, "");
				break;
       		case  4: // Delete
				knret = doKN( id , pas , flag , "" );
				break;
			case  2: // Load
				knret = doKN( id , pas , flag , process );
				break;
			case  3: // Save
					knret = doKN( id , pas , flag , process );
				break;
#endif
			default:
				knret = -7;
			}
		}
#ifdef _FIX_WORKS
		{//andy_add
			int ret;
			char buf1[256];
#ifdef _TIMEOUTKICK
			sprintf( buf1, "%d %s \n", knret, deadline);
#else
			sprintf( buf1, "%d\n", knret);
#endif
			Log( buf1);
			if((ret = write( afd, buf1, sizeof( buf1))) < 0 )	{
				close( afd);
				afd = 0;
				break;
			}
		}
		memset( linebuf, 0, sizeof( linebuf));
#else
#ifdef _TIMEOUTKICK
		fprintf( fp , "%d %s \n", knret, deadline );
#else
		fprintf( fp , "%d\n", knret );
#endif
#endif
    }
#ifdef _FIX_WORKS
	if( afd > 0 ) close( afd);
	if( csd > 0 ) close( csd);
#else
    fclose( fp );
#endif
	//if( AcLogFile != NULL)
	//	fclose( AcLogFile);
    Log( "acsv closed the connection. aborting.\n" );
}

static void parseOpt( int argc , char **argv )
{
    int c;
    int option_index;

#ifdef _ADD_AC_IP                // WON ADD 修改封包內容
	memset( AC_IP, -1 , sizeof( AC_IP) );
#endif

    if( argc == 1 ){
        fprintf( stderr , "Argument error: print usage by acwk -h\n" );
        exit(0);
    }
    
    while(1){
        static struct option long_options[] =
        {
            {"port" , 1, 0 ,'p'},
            {"debug" , 1, 0 , 'd'},
            {"help" , 0 , 0 , 'h'},
            {"logdir", 1, 0, 'l' },
            {"csaddr", 1, 0, 'a' },
            {"csport", 1, 0, 'c' },
#ifdef _ADD_AC_IP                // WON ADD 修改封包內容
			{"acaddr", 1, 0, 'w' },
#endif
            {0,0,0,0}
        };

#ifdef _FIX_MESSAGE                // WON ADD 修改封包內容
        c = getopt_long ( argc, argv, "p:dhl:a:c:w:", long_options, &option_index );
#else
        c = getopt_long ( argc, argv, "p:dhl:a:c:", long_options, &option_index );
#endif

        if( c == -1 )break;

        switch(c ){
        case 'l':
            if( optarg){
                snprintf( logdir, sizeof( logdir), "%s", optarg );
            } else{
                fprintf( stderr , "need directory name after -l.\n" );
            }
            break;
        case 'p' :
            port = atoi( optarg );
            break;
        case 'd':
            debug = 1;
            break;
        case 'h':
            fprintf( stderr,
                     "Usage: acwk [-d|--debug] [-p port|--port port] [-h|--help] [-l logdir]\n"
                     "            [-a CSAddress] [-c CSPort]\n"
                     "Default debug mode is 0.\n"
                     "\nCopyright 1999 Kengo Nakajima / Japan system supply\n"
                     );
            exit(0);
            break;
        // Spock 2000/12/5
        case 'a':
            strcpy( WGSAddress, optarg );
            break;
        case 'c':
            WGSPort = atoi( optarg );
            break;
        // Spock end
#ifdef _ADD_AC_IP				 // WON ADD 加AC_IP至通訊協定中
		case 'w':
			strcpy( AC_IP, optarg ); 
			Log( AC_IP );
			break;
#endif
        }
    }
}
Example #4
0
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;

  int fmindexi = CHAR_getWorkInt(index, CHAR_WORKFMINDEXI);
  int channel = CHAR_getWorkInt(index, CHAR_WORKFMCHANNEL);
  int quickchannel = CHAR_getWorkInt(index, CHAR_WORKFMCHANNELQUICK);
  {
    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;

  if(messageeraseescape[0] == '['
     && messageeraseescape[stringlen - 1] == ']') {
    char gm[128];
    char *pass = strstr(messageeraseescape + 1, getChatMagicPasswd());
    // Arminius: limit ip +2
    char* ip = CONNECT_get_userip(fd);
    messageeraseescape[stringlen - 1] = '\0';
    // Arminius: limit ip
    if(pass == messageeraseescape + 1) {
      if(CHAR_useChatMagic(index, messageeraseescape + 1 + strlen(getChatMagicPasswd()) + 1, TRUE)) {
        print("\n账号:%s 名字:%s\n来自ip:%s\n使用GM命令%s]\n", CHAR_getChar(index, CHAR_CDKEY), CHAR_getChar(index, CHAR_NAME), ip, 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\n来自ip:%s\n使用GM命令%s]\n", CHAR_getChar(index, CHAR_CDKEY), CHAR_getChar(index, CHAR_NAME), ip, 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)){
            player_useChatMagic( index,messageeraseescape + 1,TRUE);
            print( "\n账号:%s 名字:%s\n来自ip:%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\n来自ip:%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') {
      int point = CHAR_getInt(index, CHAR_AMPOINT);
      if(point > getPMove() || getPMove() == 0) {
        char x[4], y[4];
        easyGetTokenFromString(messageeraseescape, 2, x, sizeof(x));
        easyGetTokenFromString(messageeraseescape, 3, y, sizeof(y));
        CHAR_warpToSpecificPoint(index, CHAR_getInt(index, CHAR_FLOOR), atoi(x), atoi(y));
        CHAR_setInt(index, CHAR_AMPOINT, point - getPMove());
      } else
        CHAR_talkToCli(index, -1, "你已经没有足够的会员点数顺移了!", CHAR_COLORRED);
      return;
    }
  }
#endif

#ifdef _PLAYER_ANNOUNCE
  if(getPAnnounce() != -1) {
    if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'g' && messageeraseescape[2] == 'g') {

      int point = CHAR_getInt(index, CHAR_AMPOINT);
      if(point > getPAnnounce() || getPAnnounce() == 0) {
        int i;
        int playernum = CHAR_getPlayerMaxNum();
        char buff[255];
        char xlbmsg[255];
        char *MyName = CHAR_getChar(index, CHAR_NAME);

        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);
        }
        CHAR_setInt(index, CHAR_AMPOINT, point - getPAnnounce());
      } else
        CHAR_talkToCli(index, -1, "你已经没有足够的会员点数小喇叭了!", CHAR_COLORRED);
      return;
    }
  }
#endif

#ifdef _TALK_ACTION
  TalkAction(index, messageeraseescape);
#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) {
      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))};
    int 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) {
              talkedfunc(toindex, index, messageeraseescape, color, -1);
            }
            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;
    int talk = FALSE;
    int channelTalk = FALSE;
    int partyindex[CHAR_PARTYMAX];
    for(i = 0; i < CHAR_PARTYMAX; i++) {
      partyindex[i] = -1;
    }
    if(CHAR_getWorkInt(index, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) {
      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)
            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 < FAMILY_MAXMEMBER; i++) {
          tindex = channelMember[fmindexi][channel][i];
          if(!CHAR_CHECKINDEX(tindex))
            continue;
          if(tindex >= 0 && tindex != index) {
            typedef void (*TALKF)(int, int, char *, int, int);
            TALKF talkedfunc = NULL;

            talkedfunc = (TALKF) CHAR_getFunctionPointer(tindex, CHAR_TALKEDFUNC);

            if(talkedfunc)
              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) {
                  talkedfunc(toindex, index, messageeraseescape, color, -1);
                }
                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);
      }
    }
  }
}
Example #5
0
static int readConfig( char *path )
{
    char buf[2048];
    FILE *fp;

    fp = fopen( path , "r" );
    if( fp == NULL ){ return -2; }

    while( fgets( buf , sizeof( buf ) , fp )){
        char command[128];
        char param[128];
        chop(buf);
        
        easyGetTokenFromString( buf , 1 , command , sizeof( command ));
        easyGetTokenFromString( buf , 2 , param , sizeof( param ));

        if( strcmp( command , "port" ) == 0 ){
            port = atoi( param );
        		log( "�˿�:%d\n",port );
        } else if( strcmp( command , "logdir" ) == 0 ){
            snprintf( logdir , sizeof( logdir) , param );
            log( "��־Ŀ¼:%s\n",logdir );
        } else if( strcmp( command , "chardir" ) == 0 ){
            snprintf( chardir , sizeof( chardir) , param );
            log( "����Ŀ¼:%s\n",chardir );
#ifdef _SLEEP_CHAR
						snprintf( sleepchardir , sizeof( sleepchardir), "%s_sleep", chardir);
						log( "˯��Ŀ¼:%s\n",sleepchardir );
#endif
        } else if( strcmp( command , "pass" ) == 0 ){
        		snprintf( svpass , sizeof( svpass ) , param);
            log( "����:%s\n",param );
        } else if( strcmp( command , "dbdir" ) == 0 ){
            snprintf( dbdir , sizeof( dbdir) , param );    
            log( "����Ŀ¼:%s\n",dbdir );        
        } else if( strcmp( command, "rotate_interval" ) == 0 ){
            log_rotate_interval = atoi( param );
            log( "��־ѭ�����:%d\n",log_rotate_interval ); 
        } else if( strcmp( command, "maildir" ) == 0 ){
            snprintf( maildir, sizeof( maildir ), param );
            log( "�ʼ�Ŀ¼:%s\n",maildir );
#ifdef	_FAMILY
        // CoolFish: Family 2001/5/9
        } else if( strcmp( command, "familydir" ) == 0 ){
            snprintf( familydir, sizeof( familydir ), param );
            log( "����Ŀ¼:%s\n",familydir );
        } else if( strcmp( command, "fmpointdir" ) == 0 ){
            snprintf( fmpointdir, sizeof( fmpointdir ), param );
            log( "ׯ԰����:%s\n",fmpointdir );
        } else if( strcmp( command, "fmsmemodir" ) == 0 ){
            snprintf( fmsmemodir, sizeof( fmsmemodir ), param );
            log( "���屸��:%s\n",fmsmemodir );
#endif
			  } else if( strcmp( command , "Total_Charlist" ) == 0 ){
        	Total_Charlist = atoi( param );
        	log( "��������������:%d��\n",Total_Charlist );
        } else if( strcmp( command , "Expired_mail" ) == 0 ){
        	Expired_mail = atoi( param );
        	log( "���¹����ʼ����:%d��\n",Expired_mail );
        } else if( strcmp( command , "Del_Family_or_Member" ) == 0 ){
        	Del_Family_or_Member = atoi( param );
        	log( "ɾ�������Ա���:%d��\n",Del_Family_or_Member );
        } else if( strcmp( command , "Write_Family" ) == 0 ){
        	Write_Family = atoi( param );
        	log( "���¼�����Ϣ���:%d��\n",Write_Family );
				} else if( strcmp( command , "SameIpMun" ) == 0 ){
        	sameipmun = atoi( param );
        	if(sameipmun>0){
        		log( "ͬIP����ͬʱ��½:%d��\n",sameipmun );
        	}else{
        		log( "ͬIP����ͬʱ��½:������\n" );
        	}
				}
    }

    fclose(fp);
    return 0;
}