当前位置: 首页>>代码示例>>C++>>正文


C++ CCLOGERROR函数代码示例

本文整理汇总了C++中CCLOGERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ CCLOGERROR函数的具体用法?C++ CCLOGERROR怎么用?C++ CCLOGERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CCLOGERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getBitsPerComponent

// TODO: Get rid of this function
static int getBitsPerComponent(const QImage::Format fmt)
{
    switch(fmt)
    {
    case QImage::Format_Mono: return 1;
    case QImage::Format_MonoLSB: return 1;
    case QImage::Format_Indexed8: return 8;
    case QImage::Format_RGB32: return 8;
    case QImage::Format_ARGB32: return 8;
    case QImage::Format_ARGB32_Premultiplied: return 8;
    case QImage::Format_RGB16: return 5;
    case QImage::Format_ARGB8565_Premultiplied: return 8;
    case QImage::Format_RGB666: return 6;
    case QImage::Format_ARGB6666_Premultiplied: return 6;
    case QImage::Format_RGB555: return 5;
    case QImage::Format_ARGB8555_Premultiplied: return 5;
    case QImage::Format_RGB888: return 8;
    case QImage::Format_RGB444: return 4;
    case QImage::Format_ARGB4444_Premultiplied: return 4;
    default:
        CCLOGERROR("Unknown QImage::Format %d", fmt);
        return 0;
    }
}
开发者ID:JorgeGalingP,项目名称:cocos2d-x-qt,代码行数:25,代码来源:CCImage_qt.cpp

示例2: setInfo

void FrameAniTest::testFrameAni()
{
    setInfo("testFrameAni");
    
    auto sprite = Sprite::create("frameAni/frameAni.png",Rect(0,0,32,32));
    if (sprite == nullptr) {
        CCLOGERROR("File not found!");
        return;
    }
    
    sprite->setScale(8);
    sprite->setPosition(Point(350,400));
    this->addChild(sprite,1);
    
    
    int width = 32;
    int height = 32;
    
    Vector<cocos2d::SpriteFrame *> frameArray;
    Animate *animate = nullptr;
    
    for (int i = 0; i < 6; i ++) {
        for (int j = 0; j < 8; j ++) {
            auto spriteFrame = SpriteFrame::create("frameAni/frameAni.png", Rect(j*width, i*height, width, height));
            frameArray.pushBack(spriteFrame);
        }
    }
    
    auto animation = Animation::createWithSpriteFrames(frameArray, 0.2f);
    animate = Animate::create(animation);

    auto spawn = Spawn::create(animate, NULL);
    sprite->runAction(RepeatForever::create(spawn));
    
    
}
开发者ID:shysean,项目名称:Cocos2dxDemo,代码行数:36,代码来源:FrameAniTest.cpp

示例3: effect

void TurretDestroyState::create() {
    this->complete = true;
    BaseRenderAsset* asset = (BaseRenderAsset*)this->owner->getAsset("anime");
    asset->hide();
    Transform transform = asset->getTransform();
    Position pos = transform.getPosition();
    DestroyEffectBehaviour effect(this->owner->property);
    effect.onCreate(this->owner->getLayer(), pos);
    GeographicNode* node = this->owner->getGeographicNode();
    GeographicGateway* gateway = GeographicGateway::getInstance();
    std::vector<GeographicNode*> nodeVector = gateway->find2x2ByAddress(node->address);
    for (std::vector<GeographicNode*>::iterator it = nodeVector.begin(); it != nodeVector.end(); it++) {
        GeographicNode* node = (*it);
        node->type = BarrierBehaviourType::None;
    }
    int id = this->owner->getProperty()->getId();
    std::string barrierName = this->owner->getProperty()->getName();
    Parameter parameter;
    parameter.set<int>("id", id);
    parameter.set<std::string>("barrierName", barrierName);
    Response res = this->destoryStrategy->update(&parameter);
    if (ServiceStatus::SUCCESS != res.getStatus()) {
        CCLOGERROR("service faild %s, %s, %d", __FILE__, __FUNCTION__, __LINE__);
        res.clear();
        return;
    }
    Notifier::getInstance()->notify(NotifyMessage::Battle_Scene_Score_Update_State);
    bool showOverAllStar = res.get<bool>("showOverAllStar");
    if (false != showOverAllStar) {
        TOverAllTable record = res.get<TOverAllTable>("overAll");
        this->notifyOverAll(record);
    }
    res.clear();
    this->owner->getProperty()->setStatus(BehaviourStatus::COMPLETE);
    return;
}
开发者ID:ucreates,项目名称:clone_cofc,代码行数:36,代码来源:TurretDestroyState.cpp

示例4: CCLOGERROR

bool Socket::createSocket(int* sockfd) {
	
	if(*sockfd <= 0) {
		*sockfd = socket(AF_INET, SOCK_STREAM, 0);
		if (*sockfd < 0) {
			CCLOGERROR("ERROR opening socket");
			return false;
		}

		struct timeval tv0;
		tv0.tv_sec = 0;
		tv0.tv_usec = 0;
		struct timeval tv2;
		tv2.tv_sec = 2;
		tv2.tv_usec = 0;
		int yes = 1;

		if (setsockopt(*sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) == -1) {
			CCLOGERROR("ERROR failed to enable socket address reuse");
			return false;
		}
		if (setsockopt(*sockfd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes)) == -1) {
			CCLOGERROR("ERROR failed to enable socket port reuse");
			return false;
		}
		if (setsockopt(*sockfd, SOL_SOCKET, SO_KEEPALIVE, &yes, sizeof(tv0)) == -1) {
			CCLOGERROR("ERROR failed to enable keepalive");
			return false;
		}
		if (setsockopt(*sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv0, sizeof(tv0)) == -1) {
			CCLOGERROR("ERROR failed to disable read socket timeout");
			return false;
		}
		if (setsockopt(*sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv2, sizeof(tv2)) == -1) {
			CCLOGERROR("ERROR failed to enable send socket timeout");
			return false;
		}
	}
	
	return true;
}
开发者ID:smj10j,项目名称:LightSwarm,代码行数:41,代码来源:Socket.cpp

示例5: cc_utf16_to_utf8

/**
 * cc_utf16_to_utf8:
 * @str: a UTF-16 encoded string
 * @len: the maximum length of @str to use. If @len < 0, then
 *       the string is terminated with a 0 character.
 * @items_read: location to store number of words read, or %nullptr.
 *              If %nullptr, then %G_CONVERT_ERROR_PARTIAL_INPUT will be
 *              returned in case @str contains a trailing partial
 *              character. If an error occurs then the index of the
 *              invalid input is stored here.
 * @items_written: location to store number of bytes written, or %nullptr.
 *                 The value stored here does not include the trailing
 *                 0 byte.
 * @error: location to store the error occuring, or %nullptr to ignore
 *         errors. Any of the errors in #GConvertError other than
 *         %G_CONVERT_ERROR_NO_CONVERSION may occur.
 *
 * Convert a string from UTF-16 to UTF-8. The result will be
 * terminated with a 0 byte.
 *
 * Return value: a pointer to a newly allocated UTF-8 string.
 *               This value must be freed with free(). If an
 *               error occurs, %nullptr will be returned and
 *               @error set.
 **/
char *
cc_utf16_to_utf8 (const unsigned short  *str,
                  int             len,
                  long            *items_read,
                  long            *items_written)
{
    /* This function and g_utf16_to_ucs4 are almost exactly identical - The lines that differ
     * are marked.
     */
    const unsigned short *in;
    char *out;
    char *result = nullptr;
    int n_bytes;
    unsigned int high_surrogate;

    if (str == 0) return nullptr;

    n_bytes = 0;
    in = str;
    high_surrogate = 0;
    while ((len < 0 || in - str < len) && *in)
    {
        unsigned short c = *in;
        unsigned int wc;

        if (c >= 0xdc00 && c < 0xe000) /* low surrogate */
        {
            if (high_surrogate)
            {
                wc = SURROGATE_VALUE (high_surrogate, c);
                high_surrogate = 0;
            }
            else
            {
                CCLOGERROR("Invalid sequence in conversion input");
                goto err_out;
            }
        }
        else
        {
            if (high_surrogate)
            {
                CCLOGERROR("Invalid sequence in conversion input");
                goto err_out;
            }

            if (c >= 0xd800 && c < 0xdc00) /* high surrogate */
            {
                high_surrogate = c;
                goto next1;
            }
            else
                wc = c;
        }

        /********** DIFFERENT for UTF8/UCS4 **********/
        n_bytes += UTF8_LENGTH (wc);

next1:
        in++;
    }

    if (high_surrogate && !items_read)
    {
        CCLOGERROR("Partial character sequence at end of input");
        goto err_out;
    }

    /* At this point, everything is valid, and we just need to convert
     */
    /********** DIFFERENT for UTF8/UCS4 **********/
    result = new char[n_bytes + 1];

    high_surrogate = 0;
    out = result;
//.........这里部分代码省略.........
开发者ID:6520874,项目名称:pipiGame,代码行数:101,代码来源:ccUTF8.cpp

示例6: CCLOGERROR

void GLViewImpl::onGLFWError(int errorID, const char* errorDesc)
{
    CCLOGERROR("GLFWError #%d Happen, %s\n", errorID, errorDesc);
}
开发者ID:289,项目名称:DouPo,代码行数:4,代码来源:CCGLViewImpl-desktop.cpp

示例7: flush3D


//.........这里部分代码省略.........
            CCASSERT(cmd->getIndexCount()>= 0 && cmd->getIndexCount() < INDEX_VBO_SIZE, "VBO for index is not big enough, please break the data down or use customized render command");
            //Draw batched Triangles if VBO is full
            drawBatchedTriangles();
        }
        
        //Batch Triangles
        _batchedCommands.push_back(cmd);
        
        fillVerticesAndIndices(cmd);
        
        if(cmd->isSkipBatching())
        {
            drawBatchedTriangles();
        }
        
    }
    else if ( RenderCommand::Type::QUAD_COMMAND == commandType )
    {
        //Draw if we have batched other commands which are not quad command
        flush3D();
        flushTriangles();
        
        //Process quad command
        auto cmd = static_cast<QuadCommand*>(command);
        
        //Draw batched quads if necessary
        if(cmd->isSkipBatching()|| (_numberQuads + cmd->getQuadCount()) * 4 > VBO_SIZE )
        {
            CCASSERT(cmd->getQuadCount()>= 0 && cmd->getQuadCount() * 4 < VBO_SIZE, "VBO for vertex is not big enough, please break the data down or use customized render command");
            //Draw batched quads if VBO is full
            drawBatchedQuads();
        }
        
        //Batch Quads
        _batchQuadCommands.push_back(cmd);
        
        fillQuads(cmd);
        
        if(cmd->isSkipBatching())
        {
            drawBatchedQuads();
        }
    }
    else if (RenderCommand::Type::MESH_COMMAND == commandType)
    {
        flush2D();
        auto cmd = static_cast<MeshCommand*>(command);
        
        if (cmd->isSkipBatching() || _lastBatchedMeshCommand == nullptr || _lastBatchedMeshCommand->getMaterialID() != cmd->getMaterialID())
        {
            flush3D();
            
            if(cmd->isSkipBatching())
            {
                // XXX: execute() will call bind() and unbind()
                // but unbind() shouldn't be call if the next command is a MESH_COMMAND with Material.
                // Once most of cocos2d-x moves to Pass/StateBlock, only bind() should be used.
                cmd->execute();
            }
            else
            {
                cmd->preBatchDraw();
                cmd->batchDraw();
                _lastBatchedMeshCommand = cmd;
            }
        }
        else
        {
            cmd->batchDraw();
        }
    }
    else if(RenderCommand::Type::GROUP_COMMAND == commandType)
    {
        flush();
        int renderQueueID = ((GroupCommand*) command)->getRenderQueueID();
        visitRenderQueue(_renderGroups[renderQueueID]);
    }
    else if(RenderCommand::Type::CUSTOM_COMMAND == commandType)
    {
        flush();
        auto cmd = static_cast<CustomCommand*>(command);
        cmd->execute();
    }
    else if(RenderCommand::Type::BATCH_COMMAND == commandType)
    {
        flush();
        auto cmd = static_cast<BatchCommand*>(command);
        cmd->execute();
    }
    else if(RenderCommand::Type::PRIMITIVE_COMMAND == commandType)
    {
        flush();
        auto cmd = static_cast<PrimitiveCommand*>(command);
        cmd->execute();
    }
    else
    {
        CCLOGERROR("Unknown commands in renderQueue");
    }
}
开发者ID:Countly,项目名称:countly-sdk-cocos2d-x,代码行数:101,代码来源:CCRenderer.cpp

示例8: flush3D

void Renderer::processRenderCommand(RenderCommand* command)
{
    auto commandType = command->getType();
    if( RenderCommand::Type::TRIANGLES_COMMAND == commandType)
    {
        // flush other queues
        flush3D();

        auto cmd = static_cast<TrianglesCommand*>(command);
        
        // flush own queue when buffer is full
        if(_filledVertex + cmd->getVertexCount() > VBO_SIZE || _filledIndex + cmd->getIndexCount() > INDEX_VBO_SIZE)
        {
            CCASSERT(cmd->getVertexCount()>= 0 && cmd->getVertexCount() < VBO_SIZE, "VBO for vertex is not big enough, please break the data down or use customized render command");
            CCASSERT(cmd->getIndexCount()>= 0 && cmd->getIndexCount() < INDEX_VBO_SIZE, "VBO for index is not big enough, please break the data down or use customized render command");
            drawBatchedTriangles();
        }
        
        // queue it
        _queuedTriangleCommands.push_back(cmd);
        _filledIndex += cmd->getIndexCount();
        _filledVertex += cmd->getVertexCount();
    }
    else if (RenderCommand::Type::MESH_COMMAND == commandType)
    {
        flush2D();
        auto cmd = static_cast<MeshCommand*>(command);
        
        if (cmd->isSkipBatching() || _lastBatchedMeshCommand == nullptr || _lastBatchedMeshCommand->getMaterialID() != cmd->getMaterialID())
        {
            flush3D();

            CCGL_DEBUG_INSERT_EVENT_MARKER("RENDERER_MESH_COMMAND");

            if(cmd->isSkipBatching())
            {
                // XXX: execute() will call bind() and unbind()
                // but unbind() shouldn't be call if the next command is a MESH_COMMAND with Material.
                // Once most of cocos2d-x moves to Pass/StateBlock, only bind() should be used.
                cmd->execute();
            }
            else
            {
                cmd->preBatchDraw();
                cmd->batchDraw();
                _lastBatchedMeshCommand = cmd;
            }
        }
        else
        {
            CCGL_DEBUG_INSERT_EVENT_MARKER("RENDERER_MESH_COMMAND");
            cmd->batchDraw();
        }
    }
    else if(RenderCommand::Type::GROUP_COMMAND == commandType)
    {
        flush();
        int renderQueueID = ((GroupCommand*) command)->getRenderQueueID();
        CCGL_DEBUG_PUSH_GROUP_MARKER("RENDERER_GROUP_COMMAND");
        visitRenderQueue(_renderGroups[renderQueueID]);
        CCGL_DEBUG_POP_GROUP_MARKER();
    }
    else if(RenderCommand::Type::CUSTOM_COMMAND == commandType)
    {
        flush();
        auto cmd = static_cast<CustomCommand*>(command);
        CCGL_DEBUG_INSERT_EVENT_MARKER("RENDERER_CUSTOM_COMMAND");
        cmd->execute();
    }
    else if(RenderCommand::Type::BATCH_COMMAND == commandType)
    {
        flush();
        auto cmd = static_cast<BatchCommand*>(command);
        CCGL_DEBUG_INSERT_EVENT_MARKER("RENDERER_BATCH_COMMAND");
        cmd->execute();
    }
    else if(RenderCommand::Type::PRIMITIVE_COMMAND == commandType)
    {
        flush();
        auto cmd = static_cast<PrimitiveCommand*>(command);
        CCGL_DEBUG_INSERT_EVENT_MARKER("RENDERER_PRIMITIVE_COMMAND");
        cmd->execute();
    }
    else
    {
        CCLOGERROR("Unknown commands in renderQueue");
    }
}
开发者ID:bonlai,项目名称:3kaigame,代码行数:88,代码来源:CCRenderer.cpp

示例9: computeStringNumLines

void Label::updateContent()
{
    std::u16string utf16String;
    if (StringUtils::UTF8ToUTF16(_originalUTF8String, utf16String))
    {
        _currentUTF16String  = utf16String;
    }

    computeStringNumLines();
    if (_fontAtlas)
    {
        computeHorizontalKernings(_currentUTF16String);
    }

    if (_textSprite)
    {
        Node::removeChild(_textSprite,true);
        _textSprite = nullptr;
        if (_shadowNode)
        {
            Node::removeChild(_shadowNode,true);
            _shadowNode = nullptr;
        }
    }

    if (_fontAtlas)
    {
        alignText();
    }
    else
    {
        if (!_compatibleMode)
        {
            _fontDefinition._fontName = _systemFont;
            _fontDefinition._fontSize = _systemFontSize;

            _fontDefinition._alignment = _hAlignment;
            _fontDefinition._vertAlignment = _vAlignment;

            _fontDefinition._dimensions.width = _labelWidth;
            _fontDefinition._dimensions.height = _labelHeight;

            _fontDefinition._fontFillColor.r = _textColor.r;
            _fontDefinition._fontFillColor.g = _textColor.g;
            _fontDefinition._fontFillColor.b = _textColor.b;

            _fontDefinition._shadow._shadowEnabled = false;

            if (_currLabelEffect == LabelEffect::OUTLINE && _outlineSize > 0)
            {
                _fontDefinition._stroke._strokeEnabled = true;
                _fontDefinition._stroke._strokeSize = _outlineSize;
                _fontDefinition._stroke._strokeColor.r = _effectColor.r;
                _fontDefinition._stroke._strokeColor.g = _effectColor.g;
                _fontDefinition._stroke._strokeColor.b = _effectColor.b;
            }
            else
            {
                _fontDefinition._stroke._strokeEnabled = false;
            }

#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)
            if (_fontDefinition._stroke._strokeEnabled)
            {
                CCLOGERROR("Currently only supported on iOS and Android!");
            }
            _fontDefinition._stroke._strokeEnabled = false;
#endif
        }

        createSpriteWithFontDefinition();
    }
    _contentDirty = false;
}
开发者ID:4an70m,项目名称:Cocos2dxTest,代码行数:74,代码来源:CCLabel.cpp

示例10: flush3D

void Renderer::visitRenderQueue(const RenderQueue& queue)
{
    ssize_t size = queue.size();
    
    for (ssize_t index = 0; index < size; ++index)
    {
        auto command = queue[index];
        auto commandType = command->getType();
        if( RenderCommand::Type::TRIANGLES_COMMAND == commandType)
        {
            flush3D();
            if(_numberQuads > 0)
            {
                drawBatchedQuads();
                _lastMaterialID = 0;
            }
            
            auto cmd = static_cast<TrianglesCommand*>(command);
            //Batch Triangles
            if( _filledVertex + cmd->getVertexCount() > VBO_SIZE || _filledIndex + cmd->getIndexCount() > INDEX_VBO_SIZE)
            {
                CCASSERT(cmd->getVertexCount()>= 0 && cmd->getVertexCount() < VBO_SIZE, "VBO for vertex is not big enough, please break the data down or use customized render command");
                CCASSERT(cmd->getIndexCount()>= 0 && cmd->getIndexCount() < INDEX_VBO_SIZE, "VBO for index is not big enough, please break the data down or use customized render command");
                //Draw batched Triangles if VBO is full
                drawBatchedTriangles();
            }
            
            _batchedCommands.push_back(cmd);
            
            fillVerticesAndIndices(cmd);

        }
        else if ( RenderCommand::Type::QUAD_COMMAND == commandType )
        {
            flush3D();
            if(_filledIndex > 0)
            {
                drawBatchedTriangles();
                _lastMaterialID = 0;
            }
            auto cmd = static_cast<QuadCommand*>(command);
            //Batch quads
            if( (_numberQuads + cmd->getQuadCount()) * 4 > VBO_SIZE )
            {
                CCASSERT(cmd->getQuadCount()>= 0 && cmd->getQuadCount() * 4 < VBO_SIZE, "VBO for vertex is not big enough, please break the data down or use customized render command");
                //Draw batched quads if VBO is full
                drawBatchedQuads();
            }
            
            _batchQuadCommands.push_back(cmd);
            
            fillQuads(cmd);

        }
        else if(RenderCommand::Type::GROUP_COMMAND == commandType)
        {
            flush();
            int renderQueueID = ((GroupCommand*) command)->getRenderQueueID();
            visitRenderQueue(_renderGroups[renderQueueID]);
        }
        else if(RenderCommand::Type::CUSTOM_COMMAND == commandType)
        {
            flush();
            auto cmd = static_cast<CustomCommand*>(command);
            cmd->execute();
        }
        else if(RenderCommand::Type::BATCH_COMMAND == commandType)
        {
            flush();
            auto cmd = static_cast<BatchCommand*>(command);
            cmd->execute();
        }
        else if(RenderCommand::Type::PRIMITIVE_COMMAND == commandType)
        {
            flush();
            auto cmd = static_cast<PrimitiveCommand*>(command);
            cmd->execute();
        }
        else if (RenderCommand::Type::MESH_COMMAND == commandType)
        {
            flush2D();
            auto cmd = static_cast<MeshCommand*>(command);
            if (_lastBatchedMeshCommand == nullptr || _lastBatchedMeshCommand->getMaterialID() != cmd->getMaterialID())
            {
                flush3D();
                cmd->preBatchDraw();
                cmd->batchDraw();
                _lastBatchedMeshCommand = cmd;
            }
            else
            {
                cmd->batchDraw();
            }
        }
        else
        {
            CCLOGERROR("Unknown commands in renderQueue");
        }
    }
}
开发者ID:1284949699,项目名称:Quick-Cocos2dx-Community,代码行数:100,代码来源:CCRenderer.cpp

示例11: CCASSERT

void Properties::readProperties()
{
    CCASSERT(_data->getSize() >0, "Invalid data");

    char line[2048];
    char variable[256];
    int c;
    char* name;
    char* value;
    char* parentID;
    char* rc;
    char* rcc;
    char* rccc;
    bool comment = false;

    while (true)
    {
        // Skip whitespace at the start of lines
        skipWhiteSpace();

        // Stop when we have reached the end of the file.
        if (eof())
            break;

        // Read the next line.
        rc = readLine(line, 2048);
        if (rc == NULL)
        {
            CCLOGERROR("Error reading line from file.");
            return;
        }

        // Ignore comments
        if (comment)
        {
            // Check for end of multi-line comment at either start or end of line
            if (strncmp(line, "*/", 2) == 0)
                comment = false;
            else
            {
                trimWhiteSpace(line);
                const auto len = strlen(line);
                if (len >= 2 && strncmp(line + (len - 2), "*/", 2) == 0)
                    comment = false;
            }
        }
        else if (strncmp(line, "/*", 2) == 0)
        {
            // Start of multi-line comment (must be at start of line)
            comment = true;
        }
        else if (strncmp(line, "//", 2) != 0)
        {
            // If an '=' appears on this line, parse it as a name/value pair.
            // Note: strchr() has to be called before strtok(), or a backup of line has to be kept.
            rc = strchr(line, '=');
            if (rc != NULL)
            {
                // First token should be the property name.
                name = strtok(line, "=");
                if (name == NULL)
                {
                    CCLOGERROR("Error parsing properties file: attribute without name.");
                    return;
                }

                // Remove white-space from name.
                name = trimWhiteSpace(name);

                // Scan for next token, the property's value.
                value = strtok(NULL, "");
                if (value == NULL)
                {
                    CCLOGERROR("Error parsing properties file: attribute with name ('%s') but no value.", name);
                    return;
                }

                // Remove white-space from value.
                value = trimWhiteSpace(value);

                // Is this a variable assignment?
                if (isVariable(name, variable, 256))
                {
                    setVariable(variable, value);
                }
                else
                {
                    // Normal name/value pair
                    _properties.push_back(Property(name, value));
                }
            }
            else
            {
                parentID = NULL;

                // Get the last character on the line (ignoring whitespace).
                const char* lineEnd = trimWhiteSpace(line) + (strlen(trimWhiteSpace(line)) - 1);

                // This line might begin or end a namespace,
                // or it might be a key/value pair without '='.
//.........这里部分代码省略.........
开发者ID:1005491398,项目名称:Threes,代码行数:101,代码来源:CCProperties.cpp

示例12: connectionAccepter

void* connectionAccepter(void* threadData) {
	MessageReceiverData* messageReceiverData = (MessageReceiverData*)threadData;

	socklen_t clilen;
	struct sockaddr_in cli_addr;
	clilen = sizeof(cli_addr);
		
	while(messageReceiverData->socket != NULL && *messageReceiverData->sockfd > 0 && messageReceiverData->socket->isBound()) {
		int sockfd = *messageReceiverData->sockfd;

		fcntl(sockfd, F_SETFL, *messageReceiverData->sockFdFlags | O_NONBLOCK);
		
		fd_set rfd;
		FD_ZERO(&rfd);
		FD_SET(sockfd, &rfd);
		struct timeval tv;
		tv.tv_sec = 0;
		tv.tv_usec = 20000;	//20ms read timeout
		int retVal = select(sockfd+1, &rfd, NULL, NULL, &tv);
		//CCLOG("read accept select retVal: %d", retVal);

		if (retVal > 0) {		
		
			if(FD_ISSET(sockfd, &rfd)) {
				int newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
				if(*messageReceiverData->sockfd <= 0) {
					break;
				}
				
				if (newsockfd < 0) {
					CCLOGERROR("ERROR on accept - newsockfd=%d", newsockfd);
					return false;
				}
				CCLOG("Accepted new socket connection on socket %d", newsockfd);

				fcntl(newsockfd, F_SETFL, *messageReceiverData->sockFdFlags | O_NONBLOCK);
							
				//start our message receiver;
				MessageReceiverData* messageReceiverDataCopy = new MessageReceiverData();
				messageReceiverDataCopy->socket = messageReceiverData->socket;
				messageReceiverDataCopy->sockfd = new int(newsockfd);
				messageReceiverDataCopy->sockFdFlags = messageReceiverData->sockFdFlags;
				messageReceiverDataCopy->buffer = "";
				messageReceiverDataCopy->isSocketReady = false;
				pthread_create(&messageReceiverDataCopy->thread, NULL, &messageReceiver, messageReceiverDataCopy);

				int waitCounter = 0;
				while(waitCounter++ < 500 && !messageReceiverDataCopy->isSocketReady) {
					usleep(1000);
				}
				
				if(waitCounter >= 500) {
					CCLOGERROR("Accepted successfully but failed to setup reading from socket from socket id %d in time", messageReceiverData->socket->getId());
					close(*messageReceiverDataCopy->sockfd);
					*messageReceiverDataCopy->sockfd = 0;
					return false;
				}else {
					messageReceiverData->socket->setConnected(true);
					messageReceiverData->children.push_back(messageReceiverDataCopy);
				}
			}else {
				CCLOGERROR("Select socket doesn't match accepted rfd?");
			}
			
		}else if (retVal == 0) {
			//CCLOGERROR("Timeout on accept");
			
		}else {
			CCLOGERROR("ERROR on select for accept");
			
		}
	}

	CCLOG("Left connection accepting thread with sockfd=%d", *messageReceiverData->sockfd);

	close(*messageReceiverData->sockfd);
	*messageReceiverData->sockfd = 0;
	delete messageReceiverData;
	
	pthread_exit(0);
}
开发者ID:smj10j,项目名称:LightSwarm,代码行数:81,代码来源:Socket.cpp

示例13: CCLOG

bool Socket::connectTo(const string &hostname, const int &port, int timeout) {

	CCLOG("Connecting with socket id %d...", _id);

	if(_messageReceiverData != NULL) {
		if(*_messageReceiverData->sockfd > 0) {
			//pthread_kill(_messageReceiverData->thread, 0);
			close(*_messageReceiverData->sockfd);
			*_messageReceiverData->sockfd = 0;
			CCLOG("Set sockfd=0 in connectTo");
		}
		_messageReceiverData = NULL;
	}
	
	if(!Socket::createSocket(&_sockfd)) {
		return false;
	}
	
	//set socket to nonblocking
	if(_sockfdFlags == -1) {
		_sockfdFlags = fcntl(_sockfd, F_GETFL, 0);
	}
    fcntl(_sockfd, F_SETFL, _sockfdFlags | O_NONBLOCK);
	
	struct hostent *server;
	server = gethostbyname(hostname.c_str());
	if (server == NULL) {
		CCLOGERROR("ERROR, no such host \"%s\"", hostname.c_str());
		return false;
	}
	
	struct sockaddr_in serv_addr;
	bzero((char *) &serv_addr, sizeof(serv_addr));
	serv_addr.sin_family = AF_INET;
	bcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr, server->h_length);
	serv_addr.sin_port = htons(port);
	
	//perform a select to do a timeout
	connect(_sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr));

	fd_set rfd;
	FD_ZERO(&rfd);
	FD_SET(_sockfd, &rfd);
	struct timeval tv;
	tv.tv_sec = timeout;	//X second timeout
	tv.tv_usec = 0;
	int retVal = select(_sockfd+1, NULL, &rfd, NULL, &tv);
    CCLOG("select retVal: %d", retVal);

	bool success = false;
	if (retVal == 1) {
		int so_error;
        socklen_t slen = sizeof so_error;
        getsockopt(_sockfd, SOL_SOCKET, SO_ERROR, &so_error, &slen);
        if (so_error == 0) {
            CCLOG("Successfully connected");
            success = true;
        } else {
            CCLOGERROR("Failed to connect - error: %d", so_error);
            success = false;
        }
    } else {     
        CCLOGERROR("No socket??"); 
    }
	
	
	if(!success) {
		return false;
	}
	
	//re-enable blocking
    //fcntl(_sockfd, F_SETFL, _sockfdFlags);
		
	_isConnected = true;

	//start our message receiver;
	_messageReceiverData = new MessageReceiverData();
	_messageReceiverData->socket = this;
	_messageReceiverData->sockfd = &_sockfd;
	_messageReceiverData->sockFdFlags = &_sockfdFlags;
	_messageReceiverData->buffer = "";
	_messageReceiverData->isSocketReady = false;
	pthread_create(&_messageReceiverData->thread, NULL, &messageReceiver, _messageReceiverData);
	
	int waitCounter = 0;
	while(waitCounter++ < 500 && _messageReceiverData != NULL && !_messageReceiverData->isSocketReady) {
		usleep(1000);
	}
	
	if(waitCounter >= 500) {
		CCLOGERROR("Connected successfully but failed to setup reading from socket in time");
		disconnect(false);
		return false;
	}
	
	if(_delegate != NULL) {
		_delegate->onConnect();
	}
	
	return true;
//.........这里部分代码省略.........
开发者ID:smj10j,项目名称:LightSwarm,代码行数:101,代码来源:Socket.cpp

示例14: unload

void GameLevel::load(const std::string &levelFile) {
  unload();

  std::string buffer = levelFile.empty() ? sTemplateMap : JsonParser::getBuffer(levelFile);
  if (buffer.empty()) {
    load("");
    return;
  }
  JsonParser parser(buffer);
  if (!parser) {
    CCLOG("%s", buffer.c_str());
    CCLOGERROR("Cannot load the level file: %s", levelFile.c_str());
  }

  CCLOG("Loading level file: %s", levelFile.empty() ? "Template" : levelFile.c_str());

  auto& doc = parser.getCurrentDocument();

  std::string paletteFile = doc[LEVEL_PALETTE_FILE].GetString();
  CC_SAFE_DELETE(mPalette);
  mPalette = new ColorPalette(paletteFile);

  // Shadows.
  if (doc.HasMember(SHADOW_GROUP)) {
    mNumShadowGroup = doc[SHADOW_GROUP].Size();
    parser.parseArray(doc, SHADOW_GROUP, [&](JsonSizeT i, JsonValueT &val) {
      addShadowGroup();
      mShadows[i]->load(val);
      initShadowGroup(i);
    });
  }

  // Sprites.
  CC_ASSERT(mSpriteList.empty());
  if (doc.HasMember(GAME_SPRITES)) {
    parser.parseArray(doc, GAME_SPRITES, [&](JsonSizeT i, JsonValueT &val) {
      mSpriteList.push_back(new GameSprite());
      mSpriteList.back()->load(val);
      mGameLayer->getBlockRoot()->addChild(mSpriteList.back()->getSprite(),
                                           mSpriteList.back()->ZOrder);
    });
  }

  // Effects.
  CC_ASSERT(mEffects.empty());
  if (doc.HasMember(GAME_FX)) {
    parser.parseArray(doc, GAME_FX, [&](JsonSizeT i, JsonValueT &val) {
      mEffects.push_back(val.GetString());
    });
  }
  loadFx();

  // Objects.
  mHeroSpawnPos = doc[LEVEL_SPAWN_POS].GetVec2();
  createHero(mHeroSpawnPos);
  parser.parseArray(doc, LEVEL_BLOCK_ARRAY, [&](JsonSizeT i, JsonValueT& val) {
    mObjectManager->createObject(val);
  });

  // Update shadow right after loading objects.
  for (auto sm : mShadows) {
    sm->update(0);
  }
  
  // Time events.
  CC_ASSERT(mTimeEvents.empty());
  if (doc.HasMember(TIME_EVENTS)) {
    parser.parseArray(doc, TIME_EVENTS, [&](JsonSizeT i, JsonValueT &val) {
      auto timeEvent = new TimeEvent();
      timeEvent->load(val);
      mTimeEvents.push_back(timeEvent);
    });
  }

  updateBounds();
  mBackground->clear();
  mBackground->drawSolidRect({mBounds.getMinX(), mBounds.getMinY()},
                             {mBounds.getMaxX(), mBounds.getMaxY()},
                             Color4F(mPalette->getBackgroundColor()));

  setCurrentFile(levelFile);

  mGameLayer->afterLoad();
}
开发者ID:wangyanxing,项目名称:JumpProject,代码行数:84,代码来源:GameLevel.cpp

示例15: flush3D


//.........这里部分代码省略.........
    else if ( RenderCommand::Type::QUAD_COMMAND == commandType )
    {
        //Draw if we have batched other commands which are not quad command
        flush3D();
        flushTriangles();

        //Process quad command
        auto cmd = static_cast<QuadCommand*>(command);

        //Draw batched quads if necessary
        if(cmd->isSkipBatching()|| (_numberQuads + cmd->getQuadCount()) * 4 > VBO_SIZE )
        {
            CCASSERT(cmd->getQuadCount()>= 0 && cmd->getQuadCount() * 4 < VBO_SIZE, "VBO for vertex is not big enough, please break the data down or use customized render command");
            //Draw batched quads if VBO is full
            drawBatchedQuads();
        }

        //Batch Quads
        _batchQuadCommands.push_back(cmd);

        fillQuads(cmd);

        if(cmd->isSkipBatching())
        {
            drawBatchedQuads();
        }
    }
    else if (RenderCommand::Type::MESH_COMMAND == commandType)
    {
        flush2D();
        auto cmd = static_cast<MeshCommand*>(command);

        if (cmd->isSkipBatching() || _lastBatchedMeshCommand == nullptr || _lastBatchedMeshCommand->getMaterialID() != cmd->getMaterialID())
        {
            flush3D();

            if(cmd->isSkipBatching())
            {
                cmd->execute();
            }
            else
            {
                cmd->preBatchDraw();
                cmd->batchDraw();
                _lastBatchedMeshCommand = cmd;
            }
        }
        else
        {
            cmd->batchDraw();
        }
    }
    else if(RenderCommand::Type::GROUP_COMMAND == commandType)
    {
        flush();
        int renderQueueID = ((GroupCommand*) command)->getRenderQueueID();
        visitRenderQueue(_renderGroups[renderQueueID]);
    }
    else if(RenderCommand::Type::CUSTOM_COMMAND == commandType)
    {
        flush();
        auto cmd = static_cast<CustomCommand*>(command);
        cmd->execute();
    }
    else if(RenderCommand::Type::BATCH_COMMAND == commandType)
    {
        flush();
        auto cmd = static_cast<BatchCommand*>(command);
        cmd->execute();
    }
    else if(RenderCommand::Type::BEGIN_SCISSOR_COMMAND == commandType)
    {
        flush();
        command->execute<BeginScissorCommand>();
    }
    else if(RenderCommand::Type::END_SCISSOR_COMMAND == commandType)
    {
        flush();
        command->execute<EndScissorCommand>();
    }
    else if(RenderCommand::Type::BEGIN_STENCIL_COMMAND == commandType)
    {
        flush();
        command->execute<BeginStencilCommand>();
    }
    else if(RenderCommand::Type::AFTER_STENCIL_COMMAND == commandType)
    {
        flush();
        command->execute<AfterStencilCommand>();
    }
    else if(RenderCommand::Type::END_STENCIL_COMMAND == commandType)
    {
        flush();
        command->execute<EndStencilCommand>();
    }
    else
    {
        CCLOGERROR("Unknown commands in renderQueue");
    }
}
开发者ID:tofurama3000,项目名称:The-Obscurity-Project,代码行数:101,代码来源:CCRenderer.cpp


注:本文中的CCLOGERROR函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。