Exemple #1
0
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }

    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
    _winsize=CCDirector::sharedDirector()->getWinSize();
    // Create batch node
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile ("Sprites.plist");
    _batchNode = CCSpriteBatchNode::create ("Sprites.pvr.ccz");
    addChild ( _batchNode);

    /* bg = Component::Create (Entity_);
     bg->AddC (CocosComponent::Create (CCSprite::create ("background.png")));
     bg->AddC (MoveComponent::Create ({ 100, 100 }, 1, 300, 300, 100,1));
     DD (bg->GetID(), Telegram_SET_POS, { visibleSize.width / 2, visibleSize.height / 2 });*/


    /*


     CCPoint			 vPos,

     double			 dMass,
     double			 dMaxSpeed,
     double			 dMaxForce,
     double			 dMaxTurnRate
    */
    srand (time (NULL));

    for (int i=0; i<20; ++i)
    {

        auto   bad = Component::Create (Entity_);

        bad->AddC (RadarComponent::Create (50));
        bad->AddC (MoveComponent::Create (   { 100, 100 }, 1,100, 1000, 100,10));
        bad->AddC (CocosComponent::Create (CCSprite::createWithSpriteFrameName ("munch1.png")));
        bad->AddC (HPComponent::Create (100));
        bad->AddC (WeaponComponent::Create());
        bads.push_back (bad);

        DD (bad->GetID(), Telegram_SET_POS, { double (500 + rand() % 30), double (500 + rand() % 30) });
    }
    for (auto a:bads)
    {
        DD (a->GetID(), Telegram_SEARCH, {});
    }

    setTouchEnabled (true);
    setTouchMode (kCCTouchesOneByOne);
    scheduleUpdate();
    return true;
}
Exemple #2
0
/** Return a string describing important configuration information.
 * @return Pointer to a static buffer.
 */
const char* debug_serveropts(void)
{
  unsigned int bp;
  int i = 0;
#define AddC(c)	serveropts[i++] = (c)

  bp = feature_uint(FEAT_BUFFERPOOL);
  if (bp < 1000000) {
    AddC('b');
    if (bp > 99999)
      AddC((char)('0' + (bp / 100000)));
    if (bp > 9999)
      AddC((char)('0' + (bp / 10000) % 10));
    AddC((char)('0' + (bp / 1000) % 10));
  } else {
    AddC('B');
    if (bp > 99999999)
      AddC((char)('0' + (bp / 100000000)));
    if (bp > 9999999)
      AddC((char)('0' + (bp / 10000000) % 10));
    AddC((char)('0' + (bp / 1000000) % 10));
  }

#ifndef NDEBUG
  AddC('A');
#endif
#ifdef  DEBUGMODE
  AddC('D');
#endif

  if (feature_bool(FEAT_HUB))
    AddC('H');

  if (feature_bool(FEAT_IDLE_FROM_MSG))
    AddC('M');

  if (feature_bool(FEAT_RELIABLE_CLOCK))
    AddC('R');

#if defined(USE_POLL) && defined(HAVE_POLL_H)
  AddC('U');
#endif
#ifdef  IPV6
  AddC('6');
#endif

#if defined(USE_SSL)
  AddC('S');
#endif
#if defined(USE_ZLIB)
  AddC('Z');
#endif
#if defined(PCRE)
  AddC('P');
#endif
#if defined(UNDERNET)
  AddC('+'); AddC('U'); AddC('N'); AddC('E'); AddC('T');
#endif
#if defined(DDB)
  AddC('+'); AddC('D'); AddC('D'); AddC('B');
#endif

  serveropts[i] = '\0';

  return serveropts;
}
Exemple #3
0
Filter *Invariant(double fp, double fs, double ap, double as, double fc, int *out_n, Complex* (*FindPoles)())
{
    Complex *poles, *Ak, cplx1, cplx2; 
    Filter *filter;
    int n, i;
    double T, Ws, Wp, gain;	
    Complex Tc;

    Ws = 2 * PI * fs;
    Wp = 2 * PI * fp;
    T = 1/fc;
    Tc.re = T;
    Tc.im = 0;
    poles = FindPoles(Wp, Ws, ap, as, fc, out_n, &gain);
    n = *out_n;
    Ak = FindFactors(poles, fc, n, gain);

    filter = (Filter *)malloc(sizeof(Filter));
/* Allocate storage for output filter */
    if(n % 2)
    {
/* If n is odd there is a real pole */
	filter->num_parallels = (n + 1) / 2;
	filter->units = (FilterUnit *)malloc(sizeof(FilterUnit) * (n + 1) / 2);
	filter->units[0].num_degree = 1;
	filter->units[0].num = (double *)malloc(sizeof(double));
	filter->units[0].den_degree = 2;
	filter->units[0].den = (double *)malloc(sizeof(double) * 2);
	for(i = 1; i < (n + 1) / 2; i++)  /* For each pair of coniugate poles */
	{
	    filter->units[i].num_degree = 2;
	    filter->units[i].num = (double *)malloc(sizeof(double) * 2);
	    filter->units[i].den_degree = 3;
	    filter->units[i].den = (double *)malloc(sizeof(double) * 3);
	}
    }
    else
/* In n is even there are only pairs of coniugate poles */
    {    
	filter->num_parallels = n / 2;
	filter->units = (FilterUnit *)malloc(sizeof(FilterUnit) * n / 2);
	for(i = 0; i < n / 2; i++)  /* For each pair of coniugate poles */
	{
	    filter->units[i].num_degree = 2;
	    filter->units[i].num = (double *)malloc(sizeof(double) * 2);
	    filter->units[i].den_degree = 3;
	    filter->units[i].den = (double *)malloc(sizeof(double) * 3);
	}
    }

/* Compute filter coefficients */
    if(n % 2)
    {
	filter->units[0].num[0] = 1/Ak[0].re;
	filter->units[0].den[0] = 1;
	filter->units[0].den[1] = -exp(poles[0].re * T);
	for(i = 1; i < (n + 1)/2; i++)	    
	{
	    cplx1 = MulC(Ak[2 * i], Ak[2 * i - 1]);
	    cplx2 = AddC(Ak[2 * i], Ak[2 * i - 1]);
	    if(fabs(cplx1.im) > 1E-4 || fabs(cplx2.im) > 1E-4)  /* Must be real */
	    {
		printf("\nInternal error in Invariant conversion");
	    }
	    filter->units[i].num[0] = cplx2.re/cplx1.re;
	    cplx2 = AddC(MulC(Ak[2 * i], ExpC(MulC(Tc, poles[2 * i]))), MulC(Ak[2 * i - 1], ExpC(MulC(Tc, poles[2 * i - 1]))));
	    if(fabs(cplx2.im) > 1E-4)	/* Must be real */
	    {
		printf("\nInternal error in Invariant conversion");
	    }
	    filter->units[i].num[1] = -cplx2.re/cplx1.re;

	    filter->units[i].den[0] = 1;
	    filter->units[i].den[1] = - 2 * exp(poles[2 * i].re * T) * cos(poles[2 * i].im * T);
	    filter->units[i].den[2] = exp(2 * poles[2 * i].re * T);
	}
    }
    else	/* n even */
	for(i = 0; i < n/2; i++)	    
	{
	    cplx1 = MulC(Ak[2 * i], Ak[2 * i + 1]);
	    cplx2 = AddC(Ak[2 * i], Ak[2 * i + 1]);
	    if(fabs(cplx1.im) > 1E-4 || fabs(cplx2.im) > 1E-4)  /* Must be real */
	    {
		printf("\nInternal error in Invariant conversion");
	    }
	    filter->units[i].num[0] = cplx2.re/cplx1.re;
	    cplx2 = AddC(MulC(Ak[2 * i], ExpC(MulC(Tc, poles[2 * i]))), MulC(Ak[2 * i + 1], ExpC(MulC(Tc, poles[2 * i + 1]))));
	    if(fabs(cplx2.im) > 1E-4)	/* Must be real */
	    {
		printf("\nInternal error in Invariant conversion");
	    }
	    filter->units[i].num[1] = -cplx2.re/cplx1.re;

	    filter->units[i].den[0] = 1;
	    filter->units[i].den[1] = - 2 * exp(poles[2 * i].re * T) * cos(poles[2 * i].im * T);
	    filter->units[i].den[2] = exp(2 * poles[2 * i].re * T);
	}
    free((char *)poles);
    free((char *)Ak);
    return filter;
}
Exemple #4
0
Filter *Bilinear(double fp, double fs, double ap, double as, double fc, int *out_n, Complex* (*FindPoles)())
{
    Complex *poles, *Ak, cplx;
    Filter *filter;
    int n, i;
    double T, T2, Ws, Wp, ws, wp, gain;	
    Complex ac, a1c, bc, b1c, Ac, A1c, T2c;

/* Pre distorsion */
    wp = 2 * PI * fp/fc;
    ws = 2 * PI * fs/fc;

    Wp = 2 * tan(wp/2)*fc;
    Ws = 2 * tan(ws/2)*fc;

    T = 1/fc;
    T2 = T/2;

    poles = FindPoles(Wp, Ws, ap, as, fc, out_n, &gain);
    n = *out_n;
    Ak = FindFactors(poles, fc, n, gain); /* Remind that 1/Ak are normalized such that H(0) = T */
    for(i = 0; i < n; i++)
    {
	Ak[i].re *= T;
	Ak[i].im *= T;
    }
    filter = (Filter *)malloc(sizeof(Filter));
/* Allocate storage for output filter */
    if(n % 2)
    {
/* If n is odd there is a real pole */
	filter->num_parallels = (n + 1) / 2;
	filter->units = (FilterUnit *)malloc(sizeof(FilterUnit) * (n + 1) / 2);
	filter->units[0].num_degree = 2;
	filter->units[0].num = (double *)malloc(sizeof(double) * 2);
	filter->units[0].den_degree = 2;
	filter->units[0].den = (double *)malloc(sizeof(double) * 2);
	for(i = 1; i < (n + 1) / 2; i++)  /* For each pair of coniugate poles */
	{
	    filter->units[i].num_degree = 3;
	    filter->units[i].num = (double *)malloc(sizeof(double) * 3);
	    filter->units[i].den_degree = 3;
	    filter->units[i].den = (double *)malloc(sizeof(double) * 3);
	}
    }
    else
/* In n is even there are only pairs of coniugate poles */
    {    
	filter->num_parallels = n / 2;
	filter->units = (FilterUnit *)malloc(sizeof(FilterUnit) * n / 2);
	for(i = 0; i < n / 2; i++)  /* For each pair of coniugate poles */
	{
	    filter->units[i].num_degree = 3;
	    filter->units[i].num = (double *)malloc(sizeof(double) * 3);
	    filter->units[i].den_degree = 3;
	    filter->units[i].den = (double *)malloc(sizeof(double) * 3);
	}
    }

/* Compute filter coefficients */
    if(n % 2)
    {
	filter->units[0].num[0] = filter->units[0].num[1] = T2/Ak[0].re;
	filter->units[0].den[0] = 1 - poles[0].re * T2;
	filter->units[0].den[1] = -1 - poles[0].re * T2;
	T2c.re = T2;
	T2c.im = 0;
	for(i = 1; i < (n + 1)/2; i++)	    
	{
	    Ac = DivC(T2c, Ak[2 * i]);
	    A1c = DivC(T2c, Ak[2 * i - 1]);
	    ac.re = 1 - poles[2 * i].re * T2;
	    ac.im = -poles[2 * i].im * T2;
	    a1c.re = 1 - poles[2 * i - 1].re * T2;
	    a1c.im = -poles[2 * i - 1].im * T2;
	    bc.re = 1 + poles[2 * i].re * T2;
	    bc.im = poles[2 * i].im * T2;
	    b1c.re = 1 + poles[2 * i - 1].re * T2;
	    b1c.im = poles[2 * i - 1].im * T2;
	    cplx = AddC(MulC(A1c, ac), MulC(Ac, a1c));
	    if(fabs(cplx.im) > 1E-4)
	    {
		printf("\nInternal error in Bilinear conversion");
	    }
	    filter->units[i].num[0] = cplx.re;

 	    cplx = SubC(AddC(MulC(A1c, ac), MulC(Ac, a1c)), AddC(MulC(A1c, bc), MulC(Ac, b1c)));
	    if(fabs(cplx.im) > 1E-4)
	    {
		printf("\nInternal error in Bilinear conversion");
	    }
	    filter->units[i].num[1] = cplx.re;
	    
 	    cplx = AddC(MulC(A1c, bc), MulC(Ac, b1c));
	    if(fabs(cplx.im) > 1E-4)
	    {
		printf("\nInternal error in Bilinear conversion");
	    }
	    filter->units[i].num[2] = -cplx.re;

	    cplx = MulC(ac, a1c);
	    if(fabs(cplx.im) > 1E-4)
	    {
		printf("\nInternal error in Bilinear conversion");
	    }
	    filter->units[i].den[0] = cplx.re;

	    cplx = AddC(MulC(a1c, bc), MulC(b1c, ac));
	    if(fabs(cplx.im) > 1E-4)
	    {
		printf("\nInternal error in Bilinear conversion");
	    }
	    filter->units[i].den[1] = -cplx.re;

	    cplx = MulC(bc, b1c);
	    if(fabs(cplx.im) > 1E-4)
	    {
		printf("\nInternal error in Bilinear conversion");
	    }
	    filter->units[i].den[2] = cplx.re;
	}
    }
    else	/* n even */
    {
	T2c.re = T2;
	T2c.im = 0;
	for(i = 0; i < n/2; i++)	    
	{
	    Ac = DivC(T2c, Ak[2 * i]);
	    A1c = DivC(T2c, Ak[2 * i + 1]);
	    ac.re = 1 - poles[2 * i].re * T2;
	    ac.im = -poles[2 * i].im * T2;
	    a1c.re = 1 - poles[2 * i + 1].re * T2;
	    a1c.im = -poles[2 * i + 1].im * T2;
	    bc.re = 1 + poles[2 * i].re * T2;
	    bc.im = poles[2 * i].im * T2;
	    b1c.re = 1 + poles[2 * i + 1].re * T2;
	    b1c.im = poles[2 * i + 1].im * T2;
	    cplx = AddC(MulC(A1c, ac), MulC(Ac, a1c));
	    if(fabs(cplx.im) > 1E-5)
	    {
		printf("\nInternal error in Bilinear conversion");
	    }
	    filter->units[i].num[0] = cplx.re;

 	    cplx = SubC(AddC(MulC(A1c, ac), MulC(Ac, a1c)), AddC(MulC(A1c, bc), MulC(Ac, b1c)));
	    if(fabs(cplx.im) > 1E-5)
	    {
		printf("\nInternal error in Bilinear conversion");
	    }
	    filter->units[i].num[1] = cplx.re;
	    
 	    cplx = AddC(MulC(A1c, bc), MulC(Ac, b1c));
	    if(fabs(cplx.im) > 1E-5)
	    {
		printf("\nInternal error in Bilinear conversion");
	    }
	    filter->units[i].num[2] = -cplx.re;

	    cplx = MulC(ac, a1c);
	    if(fabs(cplx.im) > 1E-5)
	    {
		printf("\nInternal error in Bilinear conversion");
	    }
	    filter->units[i].den[0] = cplx.re;

	    cplx = AddC(MulC(a1c, bc), MulC(b1c, ac));
	    if(fabs(cplx.im) > 1E-5)
	    {
		printf("\nInternal error in Bilinear conversion");
	    }
	    filter->units[i].den[1] = -cplx.re;

	    cplx = MulC(bc, b1c);
	    if(fabs(cplx.im) > 1E-5)
	    {
		printf("\nInternal error in Bilinear conversion");
	    }
	    filter->units[i].den[2] = cplx.re;
	}
    }
    free((char *)poles);
    free((char *)Ak);
    return filter;
}
const char* debug_serveropts(void)
{
    int bp;
    int i = 0;
#define AddC(c)	serveropts[i++] = (c)

    bp = feature_int(FEAT_BUFFERPOOL);
    if (bp < 1000000) {
        AddC('b');
        if (bp > 99999)
            AddC((char)('0' + (bp / 100000)));
        if (bp > 9999)
            AddC((char)('0' + (bp / 10000) % 10));
        AddC((char)('0' + (bp / 1000) % 10));
    } else {
        AddC('B');
        if (bp > 99999999)
            AddC((char)('0' + (bp / 100000000)));
        if (bp > 9999999)
            AddC((char)('0' + (bp / 10000000) % 10));
        AddC((char)('0' + (bp / 1000000) % 10));
    }

#ifndef NDEBUG
    AddC('A');
#endif
#ifdef  DEBUGMODE
    AddC('D');
#endif

    if (feature_bool(FEAT_LOCOP_REHASH))
        AddC('e');

    if (feature_bool(FEAT_OPER_REHASH))
        AddC('E');

    if (feature_bool(FEAT_OPER_NO_CHAN_LIMIT))
        AddC('F');

    if (feature_bool(FEAT_OPER_MODE_LCHAN))
        AddC('f');

    if (feature_bool(FEAT_HUB))
        AddC('H');

    if (feature_bool(FEAT_SHOW_ALL_INVISIBLE_USERS))
        AddC('I');
    else if (feature_bool(FEAT_SHOW_INVISIBLE_USERS))
        AddC('i');

    if (feature_bool(FEAT_OPER_KILL)) {
        if (feature_bool(FEAT_LOCAL_KILL_ONLY))
            AddC('k');
        else
            AddC('K');
    }

    if (feature_bool(FEAT_OPER_WALK_THROUGH_LMODES))
        AddC('l');

    if (feature_bool(FEAT_IDLE_FROM_MSG))
        AddC('M');

    if (feature_bool(FEAT_NO_OPER_DEOP_LCHAN))
        AddC('o');

    if (feature_bool(FEAT_CRYPT_OPER_PASSWORD))
        AddC('p');

    if (feature_bool(FEAT_RELIABLE_CLOCK))
        AddC('R');

    if (feature_bool(FEAT_LOCOP_RESTART))
        AddC('s');

    if (feature_bool(FEAT_OPER_RESTART))
        AddC('S');

#if defined(USE_POLL) && defined(HAVE_POLL_H)
    AddC('U');
#endif

    if (feature_bool(FEAT_VIRTUAL_HOST))
        AddC('v');

    serveropts[i] = '\0';

    return serveropts;
}