Exemple #1
0
/*****************************************************************************************************************
	Detect if Player is Out Side of Game Area
******************************************************************************************************************/
void Player::EdgeDectection()
{
	Vector3 bump(2, 2, 0); // bump player off edge so they don't get stuck
	// right/eastern edge check
	if ((m_position.m_x + PLAYER_EDGE) >= SCREEN_W)
	{
		m_position -= bump;
		Bounce(BOUNCE);
	}
	// top/northern edge check
	else if ((m_position.m_y + PLAYER_EDGE) >= SCREEN_H)
	{
		m_position -= bump;
		Bounce(BOUNCE);
	}
	// left/western edge check
	else if ((m_position.m_x - PLAYER_EDGE) <= 0)
	{
		m_position += bump;
		Bounce(BOUNCE);
	}
	// bottom/southern edge check
	else if ((m_position.m_y - PLAYER_EDGE) <= 0)
	{
		m_position += bump;
		Bounce(BOUNCE);
	}
	// if player manages to exist game space, reset
	if (m_position.m_x > SCREEN_W || m_position.m_x < 0 || m_position.m_y > SCREEN_H || m_position.m_y < 0)
	{
		Reset();
	}
}
Exemple #2
0
func HitByHook(hook)
{
	if(!snapped)
		return;
		
	Unstuck();
	snapped = 0;
	var fx = GetEffect("Travel", this);
	RemoveEffect("Travel", this);
	SetAction("Idle");
	
	/*
	var dir;
	if(GetX() > hook->GetX())
		dir = 1;
	else
		dir = -1;*/
		
	var angle = Angle(hook->GetX(), hook->GetY(), GetX(), GetY());
	
	//var angle = fx.angle - 45 * -fx.dir;
	var xdir = Sin(angle, Speed);
	var ydir = -Cos(angle, Speed);
	//var xdir = Cos(angle, Speed);
	//var ydir = Sin(angle, Speed);
	Bounce(xdir, ydir);
}
int CParticle::UpdateDrift (int t, int nThread)
{
    m_vPos += m_vDrift * t; //(I2X (t) / 1000);

#if DBG
    CFixVector vDrift = m_vDrift;
    CFixVector::Normalize (vDrift);
    if (CFixVector::Dot (vDrift, m_vDir) < 0)
        t = t;
#endif

    if ((m_nType <= SMOKE_PARTICLES) || (m_nType == FIRE_PARTICLES)) {
        m_vDrift [X] = ChangeDir (m_vDrift [X]);
        m_vDrift [Y] = ChangeDir (m_vDrift [Y]);
        m_vDrift [Z] = ChangeDir (m_vDrift [Z]);
    }

    if (m_bHaveDir) {
        CFixVector vi = m_vDrift, vj = m_vDir;
        CFixVector::Normalize (vi);
        CFixVector::Normalize (vj);
        fix drag = Drag ();
        if (CFixVector::Dot (vi, vj) < 0)
            drag = -drag;
        m_vPos += m_vDir * drag;
    }

    int nSegment = FindSegByPos (m_vPos, m_nSegment, m_nSegment < 0, 1, (m_nType == BUBBLE_PARTICLES) ? 0 : fix (m_nRad), nThread);
    if ((0 > nSegment) && ((m_nType != WATERFALL_PARTICLES) || m_bChecked)) {
        if (m_nType == BUBBLE_PARTICLES) {
            if (SEGMENTS [nSegment].m_nType != SEGMENT_IS_WATER) {
                m_nLife = -1;
                return 0;
            }
        }
        else if (m_nType == WATERFALL_PARTICLES) {
            CFixVector vDir = m_vPos - m_vStartPos;
            if ((CFixVector::Normalize (vDir) >= I2X (1)) && (CFixVector::Dot (vDir, m_vDir) < I2X (1) / 2)) {
                m_nLife = -1;
                return 0;
            }
            if (SEGMENTS [nSegment].m_nType == SEGMENT_IS_WATER) {
                m_bChecked = 1;
                m_nLife = 500;
            }
        }
        else if (m_nTTL - m_nLife > 500) {
            m_nLife = -1;
            return 0;
        }
    }
    m_nSegment = nSegment;

    if (!Bounce (nThread))
        return 0;

    return 1;
}
Exemple #4
0
Tempo::Tempo(){
  tapIdx = 0;
  _tempo = 0;
  _shouldUpdate = false;
  _didUpdate = false;
  _isDoubleTap = false;
  heldStart = 0;
  tempoButton = Bounce();
}
Exemple #5
0
static KWBoolean
AutoBounceSMTP(
   int   status,
   IMFILE *imf,
   const MAIL_ADDR *sender,
   SMTP_ADDR *toAddress,
   int count,
   const char *relay,
   const KWBoolean validate,
   const unsigned int timeout
)
{
   int subscript;

   switch(status)
   {
      case KWNSSuccess:
         /* No problem, so do not force termination */
         return KWFalse;

      case KWNSNoNet:
         printmsg(0,"Network connection lost with %s"
                    ", requeuing for retry.",
                    relay);
         shutdownSMTP(0);
         return KWTrue;

      case KWNSNetTimeout:
         printmsg(0,"Network timeout occurred, breaking off exchange with %s"
                    " and requeuing for retry.",
                    relay );
         shutdownSMTP(timeout);
         return KWTrue;

      case KWNSTransientError:
         printmsg(0,"Transient procotol error with %s"
                     ", requeuing for retry.",
                     relay);
         shutdownSMTP(timeout);
         return KWTrue;

      default:
         Bounce(imf,
                sender,
                "SMTP Protocol Permanent Error occurred",
                GET_TRACE_BUFFER(),
                relay,
                validate);
       /* Treat all bounced addresses as processed */
       for (subscript = 0; subscript < count; subscript++)
             toAddress[subscript].processed = KWTrue;
         return KWTrue;

   } /* switch(status) */

} /* SMTPAutoBounce */
Exemple #6
0
/*
void Animal::ChangeDirection(Speed &speed)
{
	if(speed.GetDirection()==Speed::n)
		speed.SetDirection(5);
	else
	if(speed.GetDirection()==Speed::nw)
		speed.SetDirection(6);
	else
	if(speed.GetDirection()==Speed::ne)
		speed.SetDirection(4);
	else
	if(speed.GetDirection()==Speed::s)
		speed.SetDirection(1);
	else
	if(speed.GetDirection()==Speed::se)
		speed.SetDirection(2);
	else
	if(speed.GetDirection()==Speed::sw)
		speed.SetDirection(8);
	else
	if(speed.GetDirection()==Speed::w)
		speed.SetDirection(7);
	else
	if(speed.GetDirection()==Speed::e)
		speed.SetDirection(3);

}*/
void Animal::Contact()
{
	this->speed.SetDirection(WhereCanIgo());
	position=position+speed;
	boa->SetAnimalOnTab(position, this);
	Bounce(speed);
	//position=position+speed;
	//if(!(boa->CanIwalkHere(position, ground_type)))
	//	ChangeDirection(speed);	
}
Exemple #7
0
void Ball::Move() {
    ofLog(OF_LOG_NOTICE, "moved");

    
    
    _x = _x + speedX;
    _y = _y + speedY;
    Bounce();
    
    
}
Exemple #8
0
bool RayBouncer::ReflectionBounce( RayBounce& raybounce, const Ray& ray, const Scene& scene, const RayShader& shader, const PrimitiveHit& primitivehit, const real& ior1, const real& ior2, std::size_t depth ) const {
	raybounce.ray = ray;
	const Primitive& primitive = primitivehit.first;
	const PrecalculatedMaterial& material = primitivehit.second;
	const Hit& hit = primitivehit.third;

	bool hasreflectivity = std::any_of( material.reflectivity.begin( ), material.reflectivity.end( ), real_compare<std::greater<>, 0>( ) );
	if ( !hasreflectivity )
		return false;

	vec3 reflectionraydir = reflect( ray.direction, hit.normal );
	Ray reflectionray( hit.contact + reflectionraydir * scene.Bias(),
		reflectionraydir );
	Bounce( raybounce, reflectionray, scene, shader, primitivehit, depth + 1 );
	return true;
}
void PushButton::init(uint8_t pin, uint8_t options) {

    if (options & ENABLE_INTERNAL_PULLUP) {
        pinMode(pin, INPUT_PULLUP);
    } else {
        pinMode(pin, INPUT);
    }

    if (options & PRESSED_WHEN_LOW || options & ENABLE_INTERNAL_PULLUP) {
        _button_pressed_value = LOW;
    }
    else {
        _button_pressed_value = HIGH;
    }

    // Default configuration for Debounced pin
    bouncer = Bounce();
    bouncer.attach(pin);
}
Exemple #10
0
bool RayBouncer::RefractionBounce( RayBounce& raybounce, const Ray& ray, const Scene& scene, const RayShader& shader, const PrimitiveHit& primitivehit, const real& ior1, const real& ior2, std::size_t depth ) const {
	const Primitive& primitive = primitivehit.first;
	const PrecalculatedMaterial& material = primitivehit.second;
	const Hit& hit = primitivehit.third;

	bool hastransparency = std::any_of( material.refractivity.begin( ), material.refractivity.end( ), real_compare<std::less<>, 1>( ) );
	if ( !hastransparency )
		return false;

	Fur::optional<vec3> oprefractionraydir = refract( ray.direction, hit.inside ? hit.normal * real_neg_one : hit.normal, ior1, ior2 );
	if ( !oprefractionraydir )
		return false;

	// Not total internal reflection
	const vec3& refractionraydir = *oprefractionraydir;
	Ray refractionray( hit.contact + refractionraydir * scene.Bias(), refractionraydir );
	raybounce.ray = refractionray;
	Bounce( raybounce, refractionray, scene, shader, primitivehit, depth + 1 );
	return true;
}
Exemple #11
0
bool Ball::Bounce() {
    
    pix =_grayImg.getPixels();
    
    
    
    if(pix.getColor(_x, _y)!= pix.getColor(px, py)){
    
         
         int k =0;
         k= ofRandom(1, 4);
         
         if(k<2 && pix.getColor(_x-speedX, _y-speedY)!= pix.getColor(_x, _y)){
             
             speedX *= -1;
             speedY *= -1;
             return true;
         }else if(k<3 && pix.getColor(_x, _y-speedY) != pix.getColor(_x, _y)){
             
             speedX *= 1;
             speedY *= -1;
             return true;
         }else if(k<4 && pix.getColor(_x-speedX, _y) != pix.getColor(_x, _y)){
             
             speedX *= -1;
             speedY *= 1;
             return true;
         }else{
             
             Bounce();
         }
 
        
       
    
    }
    
}
Exemple #12
0
void Ball::DoUpdate(int iCurrentTime)
{
	// Move with racket if not served yet
	if (m_dVelocity[0] == 0 && m_dVelocity[1] == 0)
		m_iCurrentScreenX = m_pRacket->GetXCentre();

	m_iCurrentScreenX += m_dVelocity[0];
	m_iCurrentScreenY += m_dVelocity[1];

	// Bounce the ball off the top screen border
	if (m_iCurrentScreenY < 0) {
		// Change movement to opposite direction
		m_dVelocity[1] *= -1;
		m_iCurrentScreenY = 1;
	}

	// Bounce the ball off the left or right screen border
	if (m_iCurrentScreenX < 0) {
		m_dVelocity[0] *= -1;
		m_iCurrentScreenX = 1;
	} else if (m_iCurrentScreenX >= GetEngine()->GetScreenWidth() - m_iDrawWidth) {
		m_dVelocity[0] *= -1;
		m_iCurrentScreenX = GetEngine()->GetScreenWidth() - m_iDrawWidth;
	}

	// Detect collision with racket
	if (IsCollideRect(this, m_pRacket)) {
		// Bounce ball off racket
		Bounce();
		// Pass some racket velocity to the ball
		m_dVelocity[0] += 0.5 * m_pRacket->GetXVelocity();
	}

	// Brick collision detection is in Breakout.cpp

	RedrawObjects();
}
Exemple #13
0
/*
 *  Post netmail message for temp file. The tempfile is an FTN style message.
 *
 *  0 - All seems well.
 *  1 - Can't access messagebase.
 *  2 - Can't find netmail board.
 *
 */
int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t mdate, 
	int flags, int DoPing, unsigned int fzone, unsigned int tzone)
{
    char    	*p, *msgid = NULL, *reply = NULL, *flagstr = NULL;
    char    	name[37], *buf, *l, *r, *q, System[37], ext[4];
    int		result = 1, email = FALSE, fmpt = 0, topt = 0;
    faddr	*ta, *ra;
    fidoaddr	na, routeto, Orig;
    FILE	*sfp, *net;
    time_t	now;
    struct tm	*tm;

    Syslog('m', "Post netmail from: %s", ascfnode(f, 0xff));
    Syslog('m', "Post netmail to  : %s", ascfnode(t, 0xff));
    Syslog('m', "Post netmail subj: %s", MBSE_SS(subject));
    net_in++;

    /*
     *  Extract MSGID and REPLY kludges from this netmail.
     */
    buf = calloc(MAX_LINE_LENGTH +1, sizeof(char));
    rewind(fp);
    while ((fgets(buf, MAX_LINE_LENGTH, fp)) != NULL) {
	Striplf(buf);
	Syslogp('M', printable(buf, 0));
	if (!strncmp(buf, "\001MSGID: ", 8)) {
	    msgid = xstrcpy(buf + 8);
	    /*
	     *  Extra test to see if the mail comes from a pointaddress.
	     */
	    l = strtok(buf," \n");
	    l = strtok(NULL," \n");
	    if ((ta = parsefnode(l))) {
		if (ta->net == f->net && ta->node == f->node && !fmpt && ta->point) {
		    Syslog('m', "Setting pointinfo (%d) from MSGID", ta->point);
		    fmpt = f->point = ta->point;
		}
		if ((ta->net == f->net) && (ta->node == f->node) && (f->zone == 0)) {
		    /*
		     * Missing zone info, maybe later we will see a INTL kludge or so, but for
		     * now, just in case we fix it. And we need that for some Aka collecting
		     * sysop who doesn't know how to configure his system right.
		     */
		    Syslog('m', "No from zone set, setting zone %d from MSGID", ta->zone);
		    f->zone = ta->zone;
		    /*
		     * 99.9 % chance that the destination zone is also missing.
		     */
		    if (t->zone == 0) {
			t->zone = ta->zone;
			Syslog('m', "No dest zone set, setting zone %d from MSGID", ta->zone);
		    }
		}
		tidy_faddr(ta);
	    }
	    if (msgid)
		free(msgid);
	    msgid = NULL;
	}
	if (!strncmp(buf, "\001FMPT", 5)) {
	    p = strtok(buf, " \n");
	    p = strtok(NULL, " \n");
	    fmpt = atoi(p);
	}
	if (!strncmp(buf, "\001TOPT", 5)) {
	    p = strtok(buf, " \n");
	    p = strtok(NULL, " \n");
	    topt = atoi(p);
	}
	if (!strncmp(buf, "\001REPLY: ", 8))
	    reply = xstrcpy(buf + 8);

	/*
	 * Check DOMAIN and INTL kludges
	 */
	if (!strncmp(buf, "\001DOMAIN", 7)) {
	    l = strtok(buf," \n");
	    l = strtok(NULL," \n");
	    p = strtok(NULL," \n");
	    r = strtok(NULL," \n");
	    q = strtok(NULL," \n");
	    if ((ta = parsefnode(p))) {
		t->point = ta->point;
		t->node = ta->node;
		t->net = ta->net;
		t->zone = ta->zone;
		tidy_faddr(ta);
	    }
	    t->domain = xstrcpy(l);
	    if ((ta = parsefnode(q))) {
		f->point = ta->point;
		f->node = ta->node;
		f->net = ta->net;
		f->zone = ta->zone;
		tidy_faddr(ta);
	    }
	    f->domain = xstrcpy(r);
	} else {
	    if (!strncmp(buf, "\001INTL", 5)) {
		l = strtok(buf," \n");
		l = strtok(NULL," \n");
		r = strtok(NULL," \n");
		if ((ta = parsefnode(l))) {
		    t->point = ta->point;
		    t->node = ta->node;
		    t->net = ta->net;
		    t->zone = ta->zone;
		    if (ta->domain) {
			if (t->domain)
			    free(t->domain);
			t->domain = ta->domain;
			ta->domain = NULL;
		    }
		    tidy_faddr(ta);
		}
		if ((ta = parsefnode(r))) {
		    f->point = ta->point;
		    f->node = ta->node;
		    f->net = ta->net;
		    f->zone = ta->zone;
		    if (ta->domain) {
			if (f->domain)
			    free(f->domain);
			f->domain = ta->domain;
			ta->domain = NULL;
		    }
		    tidy_faddr(ta);
		}
	    }
	}

	/*
	 * Check FLAGS kludge
	 */
	if (!strncmp(buf, "\001FLAGS ", 7)) {
	    flagstr = xstrcpy(buf + 7);
	    Syslog('m', "^aFLAGS %s", flagstr);
	}
	if (!strncmp(buf, "\001FLAGS: ", 8)) {
	    flagstr = xstrcpy(buf + 8);
	    Syslog('m', "^aFLAGS: %s", flagstr);
	}

	/*
	 * Check for X-FTN- kludges, this could be gated email.
	 * This should be impossible.
	 */
	if (!strncmp(buf, "\001X-FTN-", 7)) {
	    email = TRUE;
	    Syslog('?', "Warning: detected ^aX-FTN- kludge in netmail");
	}
    }
    free(buf);

    /*
     *  Only set point info if there was any info.
     *  GoldED doesn't set FMPT and TOPT kludges.
     */
    if (fmpt)
	f->point = fmpt;
    if (topt)
	t->point = topt;

    /*
     * If zone info is still missing, set the defaults which came from the
     * original mail packet addressing.
     */
    if (fzone && (f->zone == 0))
	f->zone = fzone;
    if (tzone && (t->zone == 0))
	t->zone = tzone;

    l = xstrcpy(ascfnode(f, 0xff));
    r = xstrcpy(ascfnode(t, 0xff));
    Syslog('+', "Netmail from \"%s\" to \"%s\"", l, r);
    free(l);
    free(r);

    memset(&na, 0, sizeof(na));
    na.zone  = t->zone;
    na.net   = t->net;
    na.node  = t->node;
    na.point = t->point;
    if (SearchFidonet(na.zone))
	snprintf(na.domain, 13, "%s", fidonet.domain);

    switch(TrackMail(na, &routeto)) {
	case R_LOCAL:
	    /*
	     *  Check the To: field.
	     */
	    if (strchr(t->name, '@') != NULL) {
		snprintf(name, 36, "%s", strtok(t->name, "@"));
		snprintf(System, 36, "%s", strtok(NULL, "\000"));
		email = TRUE;
	    } else {
		snprintf(name, 36, "%s", t->name);
		snprintf(System, 36, "%s", CFG.sysdomain);
	    }

	    if (email) {
		/*
		 * Send this netmail via ftn2rfc -> postemail.
		 */
		return result = ftn2rfc(f, t, subject, orig, mdate, flags, fp);
	    }

	    /*
	     * If message to "sysop" or "postmaster" replace it
	     * with the sysops real name.
	     */
	    if ((strncasecmp(name, "sysop", 5) == 0) || 
		(strcasecmp(name, "postmaster") == 0) ||
		(strcasecmp(name, "coordinator") == 0)) {
		Syslog('+', "  Readdress from %s to %s", name, CFG.sysop_name);
		snprintf(name, 36, "%s", CFG.sysop_name);
	    }

	    /*
	     * If the message is a service message, check the
	     * services database to see what action is needed.
	     * First make sure that the right noderecord is loaded.
	     */
	    (void)noderecord(f);
	    p = calloc(PATH_MAX, sizeof(char));
	    snprintf(p, PATH_MAX, "%s/etc/service.data", getenv("MBSE_ROOT"));
	    if ((sfp = fopen(p, "r")) == NULL) {
		WriteError("$Can't open %s", p);
	    } else {
		fread(&servhdr, sizeof(servhdr), 1, sfp);
		while (fread(&servrec, servhdr.recsize, 1, sfp) == 1) {
		    if ((strncasecmp(servrec.Service, name, strlen(servrec.Service)) == 0) && servrec.Active) {
			switch (servrec.Action) {
			    case AREAMGR:   result = AreaMgr(f, t, msgid, subject, mdate, flags, fp);
					    break;
			    case FILEMGR:   result = FileMgr(f, t, msgid, subject, mdate, flags, fp);
					    break;
			    case EMAIL:     result = ftn2rfc(f, t, subject, orig, mdate, flags, fp);
					    if (result) {
						if (result == 2)
						    Bounce(f, t, fp, (char *)"Could not post email");
						else
						    Bounce(f, t, fp, (char *)"Could not convert to email");
					    }
					    break;
			}
			Syslog('m', "Handled service %s, rc=%d", servrec.Service, result);
			fclose(sfp);
			return result;
		    }
		}
		fclose(sfp);
	    }
	    free(p);

	    /*
	     * Ping function
	     */
	    if (!strcasecmp(name, (char *)"ping") && DoPing) {
		return Ping(f, t, fp, FALSE);
	    }

	    /*
	     * Check userlist real names, handles, unix names.
	     * Import if one fits.
	     */
	    if (SearchUser(name)) {
		return storenet(f, t, mdate, flags, subject, msgid, reply, fp, flagstr);
	    }

	    Syslog('+', "  \"%s\" is not a known BBS user", name);
	    /*
	     *  Unknown, readdress it to the sysop.
	     */
	    net_bad++;
	    Syslog('+', "  Readdress from %s to %s", name, CFG.sysop_name);
	    snprintf(name, 36, "%s", CFG.sysop_name);
	    if (SearchUser(name)) {
		return storenet(f, t, mdate, flags, subject, msgid, reply, fp, flagstr);
	    } else {
		WriteError("Readdress import failed, sysop doesn't exist. CHECK YOUR SETUP");
		return 0;
	    }
	    break;

	case R_DIRECT:
	case R_ROUTE:
	    Syslog('+', "Route netmail via %s", aka2str(routeto));
            if (!strcasecmp(t->name, (char *)"ping") && DoPing) {
                Syslog('+', "In transit \"Ping\" message detected");
                Ping(f, t, fp, TRUE);
                (void)noderecord(f);
            }

	    /*
	     * Forward this message. Will not work for unknown
	     * direct links.
	     */
	    if (SearchNode(routeto)) {
		memset(&Orig, 0, sizeof(Orig));
		ra = fido2faddr(routeto);
		ta = bestaka_s(ra);
		Orig.zone  = ta->zone;
		Orig.net   = ta->net;
		Orig.node  = ta->node;
		Orig.point = ta->point;
		tidy_faddr(ra);
		tidy_faddr(ta);

		memset(&ext, 0, sizeof(ext));
		if (nodes.PackNetmail)
		    snprintf(ext, 4, (char *)"qqq");
		else if (nodes.Crash)
		    snprintf(ext, 4, (char *)"ccc");
		else if (nodes.Hold)
		    snprintf(ext, 4, (char *)"hhh");
		else 
		    snprintf(ext, 4, (char *)"nnn");

		if ((net = OpenPkt(Orig , routeto, (char *)ext)) == NULL) {
		    net_bad++;
		    WriteError("Can't create netmail");
		    return 0;
		}
	    } else {
		/*
		 * If it's not a direct link, create a outbound
		 * .pkt anyway, better then that this mail is 
		 * lost. It gets the normal status, it might
		 * get delivered during ZMH this way.
		 */
		Syslog('!', "Warning: not a direct link, check setup");
		memset(&Orig, 0, sizeof(Orig));
		ra = fido2faddr(routeto);
		ta = bestaka_s(ra);
		Orig.zone  = ta->zone;
		Orig.net   = ta->net;
		Orig.node  = ta->node;
		Orig.point = ta->point;
		tidy_faddr(ra);
		tidy_faddr(ta);

		if ((net = OpenPkt(Orig , routeto, (char *)"nnn")) == NULL) {
		    net_bad++;
		    WriteError("Can't create netmail");
		    return 0;
		}
	    }

	    /*
	     * Now start forward.
	     */
	    Syslog('m', "Net from  %s", ascfnode(f, 0xff));
	    Syslog('m', "Net to    %s", ascfnode(t, 0xff));
	    Syslog('m', "Net flags %08x", flags);
	    Syslog('m', "Net subj  %s", subject);

	    if (AddMsgHdr(net, f, t, flags, 0, mdate, t->name, f->name, subject)) {
		WriteError("Can't write message header");
		net_bad++;
		return 0;
	    }
	    rewind(fp);

	    /*
	     * Copy all text including kludges, when
	     * finished, insert our ^aVia line.
	     */
	    buf = calloc(MAX_LINE_LENGTH +1, sizeof(char));
	    while ((fgets(buf, MAX_LINE_LENGTH, fp)) != NULL)
		fprintf(net, "%s\r", buf);

	    now = time(NULL);
	    tm = gmtime(&now);
	    ta = bestaka_s(t);
	    fprintf(net, "\001Via %s @%d%02d%02d.%02d%02d%02d.UTC mbfido %s\r", 
		ascfnode(ta, 0x1f), tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
		tm->tm_hour, tm->tm_min, tm->tm_sec, VERSION);
	    tidy_faddr(ta);

	    putc(0, net);
	    fclose(net);
	    free(buf);
	    net_out++;
	    Syslog('m', "Forward done.");
	    return 0;

	default:
	    /*
	     * If we came this far, there's definitly something wrong
	     * with this netmail.
	     */
	    WriteError("No ROUTE for this netmail");
	    net_bad++;
	    flags |= M_ORPHAN;
	    return storenet(f, t, mdate, flags, subject, msgid, reply, fp, flagstr);
	    break;
    }

    /* Never reached */
    return result;
}
Exemple #14
0
void CBlood::Update(float TimePassed)
{
	static float FrictionFraction = 0;
	FrictionFraction += TimePassed;

	if(FrictionFraction > 2.0f) // safty messure
		FrictionFraction = 0;

	int FrictionCount = 0;
	while(FrictionFraction > 0.05f)
	{
		FrictionCount++;
		//FrictionFraction -= 0.05f;
		FrictionFraction -= 0.075f;
	}

	for(int g = 0; g < NUM_GROUPS; g++)
	{
		int i = m_aFirstPart[g];
		while(i != -1)
		{
			int Next = m_aBlood[i].m_NextPart;
			//m_aBlood[i].vel += flow_get(m_aBlood[i].pos)*time_passed * m_aBlood[i].flow_affected;
			m_aBlood[i].m_Vel.y += m_aBlood[i].m_Gravity*TimePassed;

			
			// ugly way to force tiles to blood
			int OnForceTile = Collision()->IsForceTile(m_aBlood[i].m_Pos.x, m_aBlood[i].m_Pos.y+4);
			

			for(int f = 0; f < FrictionCount; f++) // apply friction
				m_aBlood[i].m_Vel *= m_aBlood[i].m_Friction;
			
			if (OnForceTile != 0)
				//m_aBlood[i].m_Vel.x = (m_aBlood[i].m_Vel.x + OnForceTile*400) / 2.0f;
				m_aBlood[i].m_Vel.x = OnForceTile*250;
				
			// move the point
			vec2 Vel = m_aBlood[i].m_Vel*TimePassed;
			
			vec2 OldVel = Vel;
			//Vel.x += OnForceTile*1;
			
			if (OnForceTile != 0)
				Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.99f, NULL);
			else
				Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.2f+0.5f*frandom(), NULL);
			//Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.8f, NULL);
			
			/*
			if (m_aBlood[i].m_Spr >= SPRITE_BONE01)
				Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.5f+0.5f*frandom(), NULL);
			else
			if (m_aBlood[i].m_Spr > SPRITE_BLOOD01)
				Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.6f+0.6f*frandom(), NULL);
			else
				Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.1f+0.8f*frandom(), NULL);
			*/
			
			// break big blood splats into smaller ones
			if (m_aBlood[i].m_Spr != SPRITE_BLOOD01 && m_aBlood[i].m_Spr < SPRITE_BONE01)
			{
				if ((Vel.y < 0 && OldVel.y > 0) || (Vel.y > 0 && OldVel.y < 0) ||
					(Vel.x < 0 && OldVel.x > 0) || (Vel.x > 0 && OldVel.x < 0))
				{
					m_aBlood[i].m_Spr = SPRITE_BLOOD01;
					m_aBlood[i].m_StartSize /= 1.75f;
					m_aBlood[i].m_EndSize /= 1.75f;
					
					Bounce(m_aBlood[i].m_Pos, RandomDir(), g);
				}
			}

			// stick to walls and ceiling
			vec2 P = m_aBlood[i].m_Pos;
			
			// not too close the floor
			if (!Collision()->IsTileSolid(P.x, P.y+16))
			{
				if (Collision()->IsTileSolid(P.x-16, P.y))
				{
					float Dist = abs(P.x-int((P.x-16)/32)*32.0f);
					
					Vel.x -= Dist*0.1f;
				}
				else
				if (Collision()->IsTileSolid(P.x+16, P.y))
				{
					float Dist = abs(P.x-int((P.x+16)/32)*32.0f);
					
					Vel.x += Dist*0.1f;
				}
				else
				if (Collision()->IsTileSolid(P.x, P.y-16))
				{
					float Dist = abs(P.y-int((P.y-16)/32)*32.0f);
					
					Vel.y -= Dist*0.005f;
					Vel.x *= 0.99f;
				}
			}

			
			m_aBlood[i].m_Vel = Vel* (1.0f/TimePassed);

			m_aBlood[i].m_Life += TimePassed;
			
			
			if (abs(m_aBlood[i].m_Vel.x) + abs(m_aBlood[i].m_Vel.y) > 60.0f)
			{
				if (m_aBlood[i].m_Rotspeed == 0.0f)
					m_aBlood[i].m_Rot = GetAngle(m_aBlood[i].m_Vel);
				else
				{
					m_aBlood[i].m_Rot += TimePassed * m_aBlood[i].m_Rotspeed;
				}
			}
			else
			{
				//if (OldVel.y < 0 && Vel.y > 0)
				//	m_aBlood[i].m_Rot = 0;				
			}
				
			// check blood death
			if(m_aBlood[i].m_Life > m_aBlood[i].m_LifeSpan)
			{
				// remove it from the group list
				if(m_aBlood[i].m_PrevPart != -1)
					m_aBlood[m_aBlood[i].m_PrevPart].m_NextPart = m_aBlood[i].m_NextPart;
				else
					m_aFirstPart[g] = m_aBlood[i].m_NextPart;

				if(m_aBlood[i].m_NextPart != -1)
					m_aBlood[m_aBlood[i].m_NextPart].m_PrevPart = m_aBlood[i].m_PrevPart;

				// insert to the free list
				if(m_FirstFree != -1)
					m_aBlood[m_FirstFree].m_PrevPart = i;
				m_aBlood[i].m_PrevPart = -1;
				m_aBlood[i].m_NextPart = m_FirstFree;
				m_FirstFree = i;
			}

			i = Next;
		}
	}
}
Exemple #15
0
#include "global.h"
#include "user_pages.h"
#include <Bounce2.h>

Bounce debouncer = Bounce();                  // Instantiate a Bounce object
byte VentilationInActual;
byte VentilationOutActual;
byte VentilationMode = MODE_COM;
boolean Refresh = false;                      // For Main Loop, to refresh things like GPIO / WS2812
unsigned long upTime = 0;                     // Seconds since start of ESP8266


void userInit() {
	// user init code here
  server.on( "/", userPage);
  server.on( "/filldynamicdata", filldynamicdata);
  server.on ( "/set", set_active_values );
  server.on ( "/get", get_active_values );
  
  //	server.on( "/style.css", sendCSS);
pinMode(LED_BUILTIN, OUTPUT);
analogWrite(LED_BUILTIN, 220);
}

void userLoop() {
	// user code here
  yield();
  // Button press
  debouncer.update();
   // Call code if Bounce fell (transition from HIGH to LOW) :
  if ( debouncer.fell() ) {
Exemple #16
0
void CBlood::Update(float TimePassed)
{
	static float FrictionFraction = 0;
	FrictionFraction += TimePassed;

	if(FrictionFraction > 2.0f) // safty messure
		FrictionFraction = 0;

	int FrictionCount = 0;
	while(FrictionFraction > 0.05f)
	{
		FrictionCount++;
		//FrictionFraction -= 0.05f;
		FrictionFraction -= 0.075f;
	}

	for(int g = 0; g < NUM_GROUPS; g++)
	{
		int i = m_aFirstPart[g];
		while(i != -1)
		{
			int Next = m_aBlood[i].m_NextPart;
			//m_aBlood[i].vel += flow_get(m_aBlood[i].pos)*time_passed * m_aBlood[i].flow_affected;
			m_aBlood[i].m_Vel.y += m_aBlood[i].m_Gravity*TimePassed;

			for(int f = 0; f < FrictionCount; f++) // apply friction
				m_aBlood[i].m_Vel *= m_aBlood[i].m_Friction;

			// move the point
			vec2 Vel = m_aBlood[i].m_Vel*TimePassed;
			
			vec2 OldVel = Vel;
			
			if (m_aBlood[i].m_Spr >= SPRITE_BONE01)
				Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.5f+0.5f*frandom(), NULL);
			else
			if (m_aBlood[i].m_Spr > SPRITE_BLOOD01)
				Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.6f+0.6f*frandom(), NULL);
			else
				Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.1f+0.8f*frandom(), NULL);
			
			// break big blood splats into smaller ones
			if (m_aBlood[i].m_Spr != SPRITE_BLOOD01 && m_aBlood[i].m_Spr < SPRITE_BONE01)
			{
				if ((Vel.y < 0 && OldVel.y > 0) || (Vel.y > 0 && OldVel.y < 0) ||
					(Vel.x < 0 && OldVel.x > 0) || (Vel.x > 0 && OldVel.x < 0))
				{
					m_aBlood[i].m_Spr = SPRITE_BLOOD01;
					m_aBlood[i].m_StartSize /= 1.75f;
					m_aBlood[i].m_EndSize /= 1.75f;
					
					Bounce(m_aBlood[i].m_Pos, RandomDir());
				}
			}
			
			m_aBlood[i].m_Vel = Vel* (1.0f/TimePassed);

			m_aBlood[i].m_Life += TimePassed;
			
			
			if (abs(m_aBlood[i].m_Vel.x) + abs(m_aBlood[i].m_Vel.y) > 60.0f)
			{
				if (m_aBlood[i].m_Rotspeed == 0.0f)
					m_aBlood[i].m_Rot = GetAngle(m_aBlood[i].m_Vel);
				else
				{
					m_aBlood[i].m_Rot += TimePassed * m_aBlood[i].m_Rotspeed;
				}
			}
				
			// check blood death
			if(m_aBlood[i].m_Life > m_aBlood[i].m_LifeSpan)
			{
				// remove it from the group list
				if(m_aBlood[i].m_PrevPart != -1)
					m_aBlood[m_aBlood[i].m_PrevPart].m_NextPart = m_aBlood[i].m_NextPart;
				else
					m_aFirstPart[g] = m_aBlood[i].m_NextPart;

				if(m_aBlood[i].m_NextPart != -1)
					m_aBlood[m_aBlood[i].m_NextPart].m_PrevPart = m_aBlood[i].m_PrevPart;

				// insert to the free list
				if(m_FirstFree != -1)
					m_aBlood[m_FirstFree].m_PrevPart = i;
				m_aBlood[i].m_PrevPart = -1;
				m_aBlood[i].m_NextPart = m_FirstFree;
				m_FirstFree = i;
			}

			i = Next;
		}
	}
}
Exemple #17
0
static int
SendSMTPPeriod(
   IMFILE *imf,                  /* Temporary input file             */
   const MAIL_ADDR *sender,      /* Originating (error) address      */
   const char *bounceAddress,    /* IN Address to report in bounces  */
   const char *relay,            /* IN relay for bounce processing   */
   const KWBoolean validate,     /* Perform bounce on failure        */
   const unsigned int timeout
)
{
   static const char mName[] = "SendSMTPPeriod";
   KWNetStatus status;

   status = SendSMTPCmdCheckReply(".", 250, timeout);

/*--------------------------------------------------------------------*/
/*       Unlike most SMTP commands, we check errors directly; we      */
/*       bounce messages here where the standard routine might        */
/*       requeue, because we don't want transmit the same message     */
/*       over and over.                                               */
/*--------------------------------------------------------------------*/

   switch(status)
   {
      case KWNSSuccess:
         break;

      case KWNSTransientError:
         printmsg(0,"%s: Transient Error processing SMTP DATA command",
                  mName);
         /* Unprocessed addresses will be retried */
         break;

      case KWNSNetTimeout:
         bufferTrace("\n***","Timeout during SMTP data transmission",0);
         Bounce(imf,
                sender,
                GET_TRACE_BUFFER(),
                relay,
                bounceAddress,
                validate);
         return status;
         break;

      case KWNSNoNet:
         bufferTrace("\n***","SMTP Network Connection Lost",0);
         Bounce(imf,
                sender,
                GET_TRACE_BUFFER(),
                relay,
                bounceAddress,
                validate);

         break;

      default:
         bufferTrace("\n***",
                    "General error during SMTP procotol exchange",
                    0);
         Bounce(imf,
                sender,
                GET_TRACE_BUFFER(),
                relay,
                bounceAddress,
                validate);
         break;

   } /* switch(status) */

   return status;

} /* SendSMTPPeriod */
Exemple #18
0
int main(void)
{
	Game Bounce( "Bounce game 1.0");
	//Bounce.fullscreen=true;
    return Bounce.start();
}
Exemple #19
0
RayBounce RayBouncer::Bounce( const Ray& ray, const Scene& scene, const RayShader& shader ) const {
	RayBounce raybounce{ };
	Bounce( raybounce, ray, scene, shader, Fur::nullopt, 0 );
	++raybounce.samples;
	return raybounce;
}
Exemple #20
0
RayBounce RayBouncer::Bounce( vec2 xy, size2 wh, const Camera& camera, const Scene& scene, const RayShader& shader ) const {
	Ray ray = camera.Compute( xy, wh );
	return Bounce( ray, scene, shader );
}
Exemple #21
0
void Player::Go(Player *P, int numplayers, const Boundary &Path, const Boundary &BLL,const Boundary &BL,const Boundary &BR,const Boundary &BRR, const Button &B, Hook h[],int numHooks)
{
	if(B.reset)
	{
		Reset();
	}

	if(caught)
	{
		Hook myHookobj = *myHook;

		y = myHookobj.getY();
		caught = myHookobj.caughtOrNot();
		
		if(!caught)
		{
			y = .5;
			z += myHookobj.getRadius()+2;
		}

	}
	else
	{
			//Does everything for the player
		//Works for every type of player. no specifications need to be given, just a lot of objects get passed in

		Input(B);//Keyboard input for all players

		//Player-Player interaction
		if(!finish)//The player hasn't finished
		{
			Race(Path);//Follow the path
			AI(P,numplayers);//Act
		}
		else
			Finished();		//Act finished
		Bounce(P,numplayers);	//Check for bounces between each player

		//Player-Env. Interaction
		DetectBoundary(BLL,BL);	//Check left boundary
		DetectBoundary(BR,BRR);	//Check right boundary
		DetectEndCond(Path);	//Check end line&beginning


	
		if(usedtobeinabound==1||inabound==1)
			MoveBound();
		else//if not in a boundary
			MoveDamp();
	
		//Combine all
		Move();
	
		//Check to see that the Players have not exicted the outer boundary
		Check(BLL, BL,Path,BR, BRR);
		CheckFinished(Path);//Check to see if the player is passed the ifinish line
		if(pt == 0)
		{
			CheckCollision(h, numHooks);
		}

	}
}
Exemple #22
0
static KWNetStatus
SendSMTPAddressCmd(
   IMFILE *imf,                  /* IN message text for bounce msg   */
   const MAIL_ADDR *sender,      /* IN sender for bounce msg         */
   SMTP_ADDR *addressee,         /* IN target addr to send to server */
   KWBoolean validate,           /* IN control for bounce process    */
   unsigned int timeout          /* IN seconds to wait for reply     */
)
{
   static const char pattern[] = "RCPT To: <%s>";
   char buffer[MAXADDR + 100];
   char *errorType = NULL;
   KWNetStatus status;
   int rep;

   /* RMAIL requires empty addresses be handled silently */
   if (! strlen(addressee->address))
   {
      addressee->processed = KWTrue;
      return KWNSPermanentError;
   }

/*--------------------------------------------------------------------*/
/*              Format and send the target address command            */
/*--------------------------------------------------------------------*/

   sprintf(buffer, pattern, addressee->address);

   status = SendSMTPCmd(buffer);

   if (status != KWNSSuccess)
      return status;

/*--------------------------------------------------------------------*/
/*            Request and verify we did get a server response         */
/*--------------------------------------------------------------------*/

   status = GetSMTPReply(timeout, &rep);

   if (status != KWNSSuccess)
      return status;

/*--------------------------------------------------------------------*/
/*       We have a valid command response, parse it further           */
/*--------------------------------------------------------------------*/

   switch (rep / 100)
   {
      case 2:
         if (rep != 250)
            printmsg(0,"Warning: Unexpected positive return code %d for address %s",
                        rep,
                        addressee->address);
         return KWNSSuccess;

      case 4:
         errorType = "Transient";
         status = KWNSTransientError;
         break;

      case 5:
         errorType = "Permanent";
         status = KWNSPermanentError;
         break;

      default:
         errorType = "Unknown";
         status = KWNSInternalError;
         break;

   } /* else switch */

/*--------------------------------------------------------------------*/
/*                     Report the error we received                   */
/*--------------------------------------------------------------------*/

   printmsg(0, "%s failure %d of address %s",
               errorType,
               rep,
               addressee->address);

   if (status != KWNSTransientError)
   {
      size_t  bufferStatus = SAVE_TRACE_BUFFER();
      sprintf(buffer, "%s SMTP procotol error %d",
                       errorType,
                       rep);

      bufferTrace("\n***", buffer, 0);
      Bounce(imf,
             sender,
             "Remote SMTP server rejected recipient address",
             GET_TRACE_BUFFER(),
             addressee->address,
             validate);
      RESTORE_TRACE_BUFFER(bufferStatus);
      addressee->processed = KWTrue;

   } /* if (status != KWNSTransientError) */
   else
      addressee->retry = KWTrue;

   return status;

} /* SendSMTPAddressCmd */