Exemple #1
0
void HttpResponse::setHttp404Status(const char* error_msg) {
    setStatusCode(HTTP_NOTFAND);
    setContentType(CONTEXT_TYPE_HTML);
    addHeader("Server", JOINTCOM_FLAG);
    if (error_msg)
        setBody(error_msg);
    else
        setBody("<HTML><TITLE>Not Found</TITLE>\r\n"
            "<BODY><P>(CODE: 404)</P>\r\n"
            "the resource is unavailable or nonexistent.\r\n"
            "</BODY></HTML>\r\n");
}
Exemple #2
0
Player::Player(TileMapLand* land)
    : Entity()
    , hitEnemy(false)
    , m_sprite_view(new AnimatedSpriteView(*this,"Animation/player.txt"))
    , m_plateforme_physics(new PlateformerPhysic(*this,land))
{
    name =  "Player";

    setBody(new Body(*this));
    body()->setSize(sf::Vector2f(16,16));
    body()->setOrigin(sf::Vector2f(8,8));
    body()->setPosition(sf::Vector2f(38,38));

    setPhysics(m_plateforme_physics);
    m_plateforme_physics->gravity = sf::Vector2f(0,0.3);
    m_plateforme_physics->max_speed = sf::Vector2f(2.0,8.0);
    m_plateforme_physics->jump_power = 8.0;
    m_plateforme_physics->walk_speed = 2.0;
    m_plateforme_physics->run_speed  = 3.0;
    m_plateforme_physics->walk_deceleration = 0.3;


    setGamepad(new KeyBoardGamePad(*this));

    setView(m_sprite_view);

}
Exemple #3
0
void Outfit::resetClothes()
{
    setHead(0);
    setBody(0);
    setLegs(0);
    setFeet(0);
}
Exemple #4
0
void HttpResponse::setStatus(HTTP_STATUS s) {
  status = s;

  if (status != HttpResponse::STATUS_200) {
    setBody(getErrorBody(status));
  }
}
Exemple #5
0
bool JabberChatService::sendMessage(const Message &message)
{
	if (!m_client)
		return false;

	auto jid = m_resourceService->bestChatJid(message.messageChat());
	if (jid.isEmpty())
		return false;

	auto xmppMessage = QXmppMessage{};

	FormattedStringPlainTextVisitor plainTextVisitor;
	message.content()->accept(&plainTextVisitor);

	auto plain = plainTextVisitor.result();
	if (rawMessageTransformerService())
		plain = QString::fromUtf8(rawMessageTransformerService()->transform(plain.toUtf8(), {message}).rawContent());

	xmppMessage.setBody(plain);
	xmppMessage.setFrom(m_client.data()->clientPresence().id());
	xmppMessage.setStamp(QDateTime::currentDateTime());
	xmppMessage.setTo(jid.full());
	xmppMessage.setType(chatMessageType(message.messageChat(), jid.bare()));

	m_client.data()->sendPacket(m_chatStateService->withSentChatState(xmppMessage));

	return true;
}
Exemple #6
0
void ColliderDetector::setActive(bool active)
{
    if (_active == active)
    {
        return;
    }

    _active = active;

#if ENABLE_PHYSICS_BOX2D_DETECT
    if (_body)
    {
        if (active)
        {
            setBody(_body);
        }
        else
        {
            for(auto object : *_colliderBodyList)
            {
                ColliderBody *colliderBody = (ColliderBody *)object;
                b2Fixture *fixture = colliderBody->getB2Fixture();

                _body->DestroyFixture(fixture);
                colliderBody->setB2Fixture(nullptr);
            }
        }
    }
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
    if (_body)
    {
        if (_active)
        {
            for(auto object : *_colliderBodyList)
            {
                ColliderBody *colliderBody = (ColliderBody *)object;
                cpShape *shape = colliderBody->getShape();
                if(shape->space_private == nullptr)
                {
                    cpSpaceAddShape(_body->space_private, shape);
                }
            }
        }
        else
        {
            for(auto object : *_colliderBodyList)
            {
                ColliderBody *colliderBody = (ColliderBody *)object;
                cpShape *shape = colliderBody->getShape();
                if (shape->space_private != nullptr)
                {
                    cpSpaceRemoveShape(_body->space_private, shape);
                }
            }
        }
    }
#endif
}
Exemple #7
0
	void
	resp_t::setBody(QString& v)
	{
		//	std::lock_guard< std::mutex >	l(m_mutex);
		http::resp_vec_t			a(v.toUtf8());

		setBody(a);
		return;
	}
Exemple #8
0
void HttpResponse::setHttp501Status() {
    setStatusCode(HTTP_METHODERROR);
    setContentType(CONTEXT_TYPE_HTML);
    addHeader("Server", JOINTCOM_FLAG);
    setBody("<HTML><TITLE>Method Not FOUND</TITLE>\r\n"
            "<BODY><P>(CODE: 501)</P>\r\n"
            "HTTP request method not supported.\r\n"
            "</BODY></HTML>\r\n");
}
Exemple #9
0
void HttpResponse::setHttp400Status() {
    setStatusCode(HTTP_REQERROR);
    setContentType(CONTEXT_TYPE_HTML);
    addHeader("Server", JOINTCOM_FLAG);
    setBody("<HTML><TITLE>Not Found</TITLE>\r\n"
            "<BODY><P>(CODE: 400)</P>\r\n"
            "Your browser sent a bad request.\r\n"
            "</BODY></HTML>\r\n");
}
void DailymotionComment::loadComment(const QVariantMap &comment) {
    setBody(comment.value("message").toString());
    setDate(QDateTime::fromTime_t(comment.value("created_time").toLongLong()).toString("dd MMM yyyy"));
    setId(comment.value("id").toString());
    setThumbnailUrl(comment.value("owner.avatar_60_url").toString());
    setUserId(comment.value("owner.id").toString());
    setUsername(comment.value("owner.screenname").toString());
    setVideoId(comment.value("video.id").toString());
}
// Sets all data automatically
void cUOTxConfirmLogin::fromChar( P_CHAR pChar )
{
	setSerial( pChar->serial );
	setBody( pChar->id() );
	setDirection( pChar->dir );
	setX( pChar->pos.x );
	setY( pChar->pos.y );
	setZ( pChar->pos.z );
}
Exemple #12
0
void PhysicSystem::handleInit(GQE::IEntity* theEntity)
{
   GQE::IEntity* aFather = theEntity->mProperties.get<GQE::IEntity*>(PARENT);
   b2Body* aBody = 0;

   if (aFather)
   {
      b2Body* aFatherBody = aFather->mProperties.get<b2Body*>(BODY);
      b2JointDef*  aJointDef = theEntity->mProperties.get<b2JointDef*>(JOINTDEF);

      if(aJointDef)
      {
         switch(aJointDef->type)
         {
         case b2JointType::e_weldJoint:
            {
               GQE::typePropertyID aPropertyName = theEntity->mProperties.get<GQE::typePropertyID>(ANCHOR_POINT);
               b2Vec2 aFatherAnchorPoint = aFather->mProperties.get<b2Vec2>(aPropertyName);
               b2WeldJointDef* aWeldJointDef = static_cast<b2WeldJointDef*>(aJointDef);
               aWeldJointDef->localAnchorA = aFatherAnchorPoint;
               b2Vec2 aPosition = aFatherBody->GetPosition() + aFatherAnchorPoint + aWeldJointDef->localAnchorB;
               theEntity->mProperties.set<Position2D>(POSITION, Position2D(aPosition.x, aPosition.y, 0));
               break;
            }
         default:
            break;
         }

         aBody = setBody(theEntity);
         aJointDef->bodyA = aFatherBody;
         aJointDef->bodyB = aBody;
         b2Joint* aJoint = mWorld.CreateJoint(aJointDef);
         theEntity->mProperties.set<b2Joint*>(JOINT, aJoint);
      }
   }

   else
   {
      aBody = setBody(theEntity);
   }

   aBody->SetActive(true);
}
Exemple #13
0
void ForumMessage::copyFrom(ForumMessage * o) {
    setId(o->id());
    setOrdernum(o->ordernum());
    setUrl(o->url());
    setName(o->name());
    setAuthor(o->author());
    setLastchange(o->lastchange());
    setBody(o->body());
    setRead(o->isRead(), false);
}
Exemple #14
0
Shadow::Shadow(World *world) : Ghost(world)
{
    CL_Sizef fieldSize = world->getLevel()->getFieldSize();
    //Startposition ist die rechte, obere Ecke
    position = CL_Pointf(26 * fieldSize.width + fieldSize.width / 2, 1 * fieldSize.height + fieldSize.height / 2);
    currentField = getIndices(position);

    setBody("Shadow");

    onFieldCenter();
}
void TMailMessage::parse(const QString &str)
{
    QRegExp rx("(\\n\\n|\\r\\n\\r\\n)", Qt::CaseSensitive, QRegExp::RegExp2);
    int idx = rx.indexIn(str, 0);
    int bdidx = idx + rx.matchedLength();

    if (idx < 0) {
        tError("Not found mail headers");
        setBody(str);
    } else {
        QString header = str.left(idx);
        QByteArray ba;
        ba.reserve((int)(header.length() * 1.2));
        int i = 0;
        while (i < header.length()) {
            char c = header[i].toLatin1();
            if (c > 0) {
                ba += c;
                ++i;
            } else {  // not Latin-1 char
                int j = indexOfUsAscii(header, i);
                if (j < 0) {
                    j = header.length();
                }

                ba += THttpUtility::toMimeEncoded(header.mid(i, j - i), textCodec);
                i = j;
            }
        }

        // Parses header
        TInternetMessageHeader::parse(ba);
        addRecipients(addresses("To"));
        addRecipients(addresses("Cc"));
        addRecipients(addresses("Bcc"));

        // Sets body
        QString body = str.mid(bdidx);
        setBody(body);
    }
}
void AddNoteDialog::setThread( const Thread & thread )
{
	mThread = thread;
	setSubject( mThread.topic() );
	setElement( mThread.element() );
	setJobs( ThreadList(mThread.job()) );
	setBody( mThread.body() );
	appendList( mThread.threadNotifies().users() );
    if( mThread.isRecord() )
        mAttachmentList->addItems( mThread.attachmentFiles() );
    mReplyThread = mThread.reply();
}
void CIrrOdeGeomCylinder::initPhysics() {
  if (m_bPhysicsInitialized) return;

  updateAbsolutePosition();
  m_pSpace=reinterpret_cast<CIrrOdeSpace *>(getAncestorOfType((irr::scene::ESCENE_NODE_TYPE)IRR_ODE_SPACE_ID));
  if (!m_pSpace) m_pSpace=m_pWorld->getSpace();

  if (m_fRadius==0.0f && m_fLength==0.0f) {
    irr::scene::IAnimatedMeshSceneNode *pParent=reinterpret_cast<irr::scene::IAnimatedMeshSceneNode *>(getParent());
    irr::scene::IMesh *pMesh=pParent->getMesh()->getMesh(0);

    m_fRadius=pMesh->getBoundingBox().getExtent().X*getParent()->getScale().X;
    m_fLength=pMesh->getBoundingBox().getExtent().Z*getParent()->getScale().Z;

    #ifdef _TRACE_INIT_PHYSICS
      printf("CIrrOdeGeomCylinder::initPhysics: getting size from parent node\n");
      printf("CIrrOdeGeomCylinder::initPhysics: radius=%.2f, length=%.2f\n",m_fRadius,m_fLength);
    #endif
  }

  m_iGeomId=m_pOdeDevice->geomCreateCylinder(m_pSpace->getSpaceId(),m_fRadius,m_fLength);

  if (m_iGeomId) {
    m_pOdeDevice->geomSetPosition(m_iGeomId,getAbsolutePosition());

    if (m_pBody) {
      if (m_fMass) {
        m_pOdeDevice->massSetZero(m_iMass);
        m_pOdeDevice->massSetCylinderTotal(m_iMass,m_fMass,3,m_fRadius,m_fLength);
        m_pBody->addMass(m_iMass);
        //m_pOdeDevice->bodySetMass(m_pBody->getBodyId(),m_iMass);
      }
      setBody(m_pBody);
    }
    else {
      //m_pOdeDevice->geomSetCategoryBits(m_iGeomId,1);
      m_pOdeDevice->geomSetCollisionBits(m_iGeomId,0);
    }
  }
  #ifdef _TRACE_INIT_PHYSICS
    printf("CIrrOdeGeomCylinder::initPhysics: %i\n",(int)m_iGeomId);
    printf("CIrrOdeGeomCylinder extent: %.2f, %.2f\n",m_fRadius,m_fLength);
    printf("CIrrOdeGeomCylinder mass: %.2f\n",m_fMass);
  #endif

  #ifdef _DRAW_BOUNDING_BOXES
    m_cBoundingBox=getParent()->getBoundingBox();
  #endif

  m_pOdeDevice->geomSetData(m_iGeomId,this);
  CIrrOdeGeom::initPhysics();
}
Exemple #18
0
void Level::readBody(std::fstream& stream, Prototype* game)
{
	b2BodyDef bodyDef;

	bodyDef.type = b2_staticBody;
	bodyDef.position = b2Vec2(0.0f, 0.0f);
	bodyDef.angle = 0;
	bodyDef.fixedRotation = true;

	setBody(&bodyDef, game->world);

	unsigned int numberOfFixtures;
	
	stream.read((char*)&numberOfFixtures, sizeof(numberOfFixtures));

	for (unsigned int i = 0; i < numberOfFixtures; i++)
	{
		b2FixtureDef fixtureDef;

		b2ChainShape shape;

		int vertexCount;
		b2Vec2* vertices;

		stream.read((char*)&vertexCount, sizeof(vertexCount));
		vertices = new b2Vec2[vertexCount];
		stream.read((char*)vertices, vertexCount * sizeof(b2Vec2));

		shape.CreateChain(vertices, vertexCount);

		delete[] vertices;

		fixtureDef.shape = &shape;

		float32 friction;	
		float32 restitution;	
		int		userData;		
		
		stream.read((char*)&friction, sizeof(friction));
		stream.read((char*)&restitution, sizeof(restitution));
		stream.read((char*)&userData, sizeof(userData));
		
		fixtureDef.friction		= friction;
		fixtureDef.restitution	= restitution;
		fixtureDef.userData		= new int(userData);
		
		addFixture(&fixtureDef);

	}


}
std::shared_ptr<Physics2DBody> PhysicsCocos2DWorld::addBody(cocos2d::Sprite* sprite, const std::string &bodyName, const std::string &bodyPrototype) {
    auto loader = PhysicsShapeCache::getInstance();
    auto body = loader->createBodyWithName(bodyPrototype);
    
    sprite->setPhysicsBody(body);
    auto pBody = std::make_shared<PhysicsCocos2DBody>();
    pBody->setBody(body);
    pBody->setSprite(sprite);
    pBody->setName(bodyName);
    
    _bodies.push_back(pBody);
    _bodyMapByName[bodyName] = pBody;
    return pBody;
}
Exemple #20
0
void plexser::buildFuncHeader(char first, std::pair<std::string, char> cur)
{
	dbg::trace tr("plexser", DBG_HERE);

	std::string cls;
	memfunc mem;

	setFuncInfo(mem);

	setParamList(mem);
	setBody(mem);


	cppclass* curclass = mem.getClass();
	curclass->addfunc(mem);
}
Exemple #21
0
 void setBodyWithSkel(const BrfBody &b, const BrfSkeleton &s){
   int size = (int)b.part.size();
   if ((int)s.bone.size()!=size) {
       setBody(b); return;
   }
   emit(layoutAboutToBeChanged());
   vec.clear();
   for (int i=0; i<size; i++) {
       if (b.part[i].IsEmpty()) {
           vec.push_back(QString("(%1)").arg(s.bone[i].name));
       } else {
           vec.push_back(s.bone[i].name);
       }
   }
   emit(layoutChanged());
   emit(this->dataChanged(createIndex(0,0),createIndex(1,100)));
 }
std::shared_ptr<Physics2DBody> PhysicsCocos2DWorld::addBodyCircle(cocos2d::Sprite* sprite,
                                               const std::string &bodyName,
                                               float radius,
                                               PhysicsMaterial material) {
    
    auto physicsBody = PhysicsBody::createCircle(radius, material);
    physicsBody->setDynamic(false);
    sprite->setPhysicsBody(physicsBody);
    
    auto pBody = std::make_shared<PhysicsCocos2DBody>();
    pBody->setBody(physicsBody);
    pBody->setSprite(sprite);
    pBody->setName(bodyName);
    
    _bodies.push_back(pBody);
    _bodyMapByName[bodyName] = pBody;
    return pBody;
}
Exemple #23
0
WebKitNotification::WebKitNotification(const String& title, const String& body, const String& iconUrl, ExecutionContext* context, ExceptionState& es, PassRefPtr<NotificationCenter> provider)
    : NotificationBase(title, context, provider->client())
{
    ScriptWrappable::init(this);

    if (provider->checkPermission() != NotificationClient::PermissionAllowed) {
        es.throwSecurityError("Notification permission has not been granted.");
        return;
    }

    KURL icon = iconUrl.isEmpty() ? KURL() : executionContext()->completeURL(iconUrl);
    if (!icon.isEmpty() && !icon.isValid()) {
        es.throwDOMException(SyntaxError, "'" + iconUrl + "' is not a valid icon URL.");
        return;
    }

    setBody(body);
    setIconUrl(icon);
}
Exemple #24
0
llvm::Value * StructGen::emit(VflModule & module, StructAST & node)
{
    std::vector<llvm::Type*> memberTypes;
    std::vector<std::string> members;

    auto structType = llvm::StructType::create(llvm::getGlobalContext(), node.getName());
    module.getTypeSystem().addStructType(node.getName(), structType);

    for (auto member : node.getMembers()) {
        members.push_back(member->getName());
        memberTypes.push_back(member->getType()->toLLVM(module.getTypeSystem()));
    }

    if (structType->isOpaque()) {
        structType->setBody(memberTypes, false);
    }

    module.getTypeSystem().setStructMembers(node.getName(), members);

    return nullptr;
}
Exemple #25
0
llvm::Value * Generator::visit(Struct & node)
{
    std::vector<llvm::Type*> memberTypes;
    std::vector<std::string> members;

    auto structType = llvm::StructType::create(*context, node.name);
    typeSys.addStructType(node.name, structType);

    for (auto m : node.members) {
        members.push_back(m->name);
        memberTypes.push_back(m->type->getType(typeSys));
    }

    if (structType->isOpaque()) {
        structType->setBody(memberTypes, false);
    }

    typeSys.setStructMembers(node.name, members);

    return nullptr;
}
Exemple #26
0
bool JabberChatService::sendRawMessage(const Chat &chat, const QByteArray &rawMessage)
{
	if (!m_client)
		return false;

	auto jid = m_resourceService->bestChatJid(chat);
	if (jid.isEmpty())
		return false;

	auto xmppMessage = QXmppMessage{};

	xmppMessage.setBody(rawMessage);
	xmppMessage.setFrom(m_client.data()->clientPresence().id());
	xmppMessage.setStamp(QDateTime::currentDateTime());
	xmppMessage.setTo(jid.full());
	xmppMessage.setType(chatMessageType(chat, jid.bare()));

	m_client.data()->sendPacket(m_chatStateService->withSentChatState(xmppMessage));

	return true;
}
Exemple #27
0
bool TiledObject::setCollisionIndex(int index)
{
    if(m_collisionIndex == index)
        return false;
    if(index < -1 || index > m_collisionItems.count())
    {
        qWarning() << "TiledObject: Collision index out of range.";
        return false;
    }
    if(index == -1 || index == m_collisionItems.count())
    {
        m_collisionIndex = index;
        emit collisionIndexChanged();
        return false;
    }

    if(index >= 0 && index < m_collisionItems.count())
    {
        CollisionItem *item = m_collisionItems[index];
        if(!item)
            return false;

        setProperties(item->properties());
        setX(item->x());
        setY(item->y());
        setWidth(item->width());
        setHeight(item->height());
        setRotation(item->rotation());

        setVisible(item->isVisible());
        setId(item->id());
        setBody(item->body());
    }

    m_collisionIndex = index;
    emit collisionIndexChanged();

    return true;
}
Exemple #28
0
WallBlock::WallBlock(int x, int y) {
    setBody(Body(this, x, y));
}
Exemple #29
0
void QMessage::setBody(QTextStream &in, const QByteArray &mimeType)
{
    // Note we have to read the data from the stream, in order to determine the relevant charset
    setBody(in.readAll(), mimeType);
}
void SendFrame::set_message(string msg) {
	setBody(msg);
}