• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ VectorBuffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: msg

void Chat::HandleNetworkMessage(StringHash eventType, VariantMap& eventData)
{
    Network* network = GetSubsystem<Network>();
    
    using namespace NetworkMessage;
    
    int msgID = eventData[P_MESSAGEID].GetInt();
    if (msgID == MSG_CHAT)
    {
        const PODVector<unsigned char>& data = eventData[P_DATA].GetBuffer();
        // Use a MemoryBuffer to read the message data so that there is no unnecessary copying
        MemoryBuffer msg(data);
        String text = msg.ReadString();
        
        // If we are the server, prepend the sender's IP address and port and echo to everyone
        // If we are a client, just display the message
        if (network->IsServerRunning())
        {
            Connection* sender = static_cast<Connection*>(eventData[P_CONNECTION].GetPtr());
            
            text = sender->ToString() + " " + text;
            
            VectorBuffer sendMsg;
            sendMsg.WriteString(text);
            // Broadcast as in-order and reliable
            network->BroadcastMessage(MSG_CHAT, true, true, sendMsg);
        }
        
        ShowChatText(text);
    }
}
开发者ID:3dicc,项目名称:Urho3D,代码行数:31,代码来源:Chat.cpp


示例2: Save

bool Node::Save(Serializer& dest)
{
    // Write node ID
    if (!dest.WriteUInt(id_))
        return false;
    
    // Write attributes
    if (!Serializable::Save(dest))
        return false;
    
    // Write components
    dest.WriteVLE(components_.Size());
    for (unsigned i = 0; i < components_.Size(); ++i)
    {
        Component* component = components_[i];
        // Create a separate buffer to be able to skip unknown components during deserialization
        VectorBuffer compBuffer;
        if (!component->Save(compBuffer))
            return false;
        dest.WriteVLE(compBuffer.GetSize());
        dest.Write(compBuffer.GetData(), compBuffer.GetSize());
    }
    
    // Write child nodes
    dest.WriteVLE(children_.Size());
    for (unsigned i = 0; i < children_.Size(); ++i)
    {
        Node* node = children_[i];
        if (!node->Save(dest))
            return false;
    }
    
    return true;
}
开发者ID:acremean,项目名称:urho3d,代码行数:34,代码来源:Node.cpp


示例3: write_node

//
// write_node
//
void ClientSidePrediction::write_node(VectorBuffer& message, Node& node)
{
    // Write node ID
    message.WriteUInt(node.GetID());

    // Write attributes
    write_network_attributes(node, message);

    // Write user variables
    const auto& vars = node.GetVars();
    message.WriteVLE(vars.Size());
    for (auto i = vars.Begin(); i != vars.End(); ++i)
    {
        message.WriteStringHash(i->first_);
        message.WriteVariant(i->second_);
    }

    // Write number of components
    message.WriteVLE(node.GetNumComponents());

    // Write components
    const auto& components = node.GetComponents();
    for (unsigned i = 0; i < components.Size(); ++i)
    {
        auto component = components[i];
        write_component(message, *component);
    }
}
开发者ID:rasteron,项目名称:Urho3D-CSP,代码行数:31,代码来源:ClientSidePrediction.cpp


示例4: ToString

String XMLFile::ToString(const String& indentation) const
{
    VectorBuffer dest;
    XMLWriter writer(dest);
    document_->save(writer, indentation.CString());
    return String((const char*)dest.GetData(), dest.GetSize());
}
开发者ID:03050903,项目名称:Urho3D,代码行数:7,代码来源:XMLFile.cpp


示例5: DecompressVectorBuffer

VectorBuffer DecompressVectorBuffer(VectorBuffer& src)
{
    VectorBuffer ret;
    src.Seek(0);
    DecompressStream(ret, src);
    ret.Seek(0);
    return ret;
}
开发者ID:Hevedy,项目名称:Urho3D,代码行数:8,代码来源:Compression.cpp


示例6: write_component

//
// write_component
//
void ClientSidePrediction::write_component(VectorBuffer& message, Component& component)
{
    // Write ID
    message.WriteUInt(component.GetID());
    // Write type
    message.WriteStringHash(component.GetType());
    // Write attributes
    write_network_attributes(component, message);
}
开发者ID:rasteron,项目名称:Urho3D-CSP,代码行数:12,代码来源:ClientSidePrediction.cpp


示例7:

std::vector<unsigned char> CollisionChain2D::GetVerticesAttr() const
{
    VectorBuffer ret;

    for (unsigned i = 0; i < vertices_.size(); ++i)
        ret.WriteVector2(vertices_[i]);

    return ret.GetBuffer();
}
开发者ID:nemerle,项目名称:lutefisk3d,代码行数:9,代码来源:CollisionChain2D.cpp


示例8: GetDetourCrowdAgent

PODVector<unsigned char> CrowdAgent::GetAgentDataAttr() const
{
    const dtCrowdAgent* agent = GetDetourCrowdAgent();
    if (!agent)
        return Variant::emptyBuffer;

    // Reading it back in isn't this simple, see SetAgentDataAttr
    VectorBuffer ret;
    ret.Write(agent, sizeof(dtCrowdAgent));

    return ret.GetBuffer();
}
开发者ID:hendradarwin,项目名称:Urho3D,代码行数:12,代码来源:CrowdAgent.cpp


示例9:

PODVector<unsigned char> ScriptInstance::GetScriptDataAttr() const
{
    if (!scriptObject_ || !methods_[METHOD_SAVE])
        return PODVector<unsigned char>();
    else
    {
        VectorBuffer buf;
        VariantVector parameters;
        parameters.Push(Variant((void*)static_cast<Serializer*>(&buf)));
        scriptFile_->Execute(scriptObject_, methods_[METHOD_SAVE], parameters);
        return buf.GetBuffer();
    }
}
开发者ID:acremean,项目名称:urho3d,代码行数:13,代码来源:ScriptInstance.cpp


示例10: sizeof

PODVector<unsigned char> CrowdAgent::GetAgentDataAttr() const
{
    if (!inCrowd_ || !crowdManager_ || !IsEnabled())
        return Variant::emptyBuffer;
    dtCrowd* crowd = crowdManager_->GetCrowd();
    const dtCrowdAgent* agent = crowd->getAgent(agentCrowdId_);
    
    // Reading it back in isn't this simple, see SetAgentDataAttr
    VectorBuffer ret;
    ret.Write(agent, sizeof(dtCrowdAgent));

    return ret.GetBuffer();
}
开发者ID:vivienneanthony,项目名称:Urho3D-gameeconomic,代码行数:13,代码来源:CrowdAgent.cpp


示例11: LOGINFO

void Network::OnServerConnected()
{
    serverConnection_->SetConnectPending(false);
    
    LOGINFO("Connected to server");
    
    // Send the identity map now
    VectorBuffer msg;
    msg.WriteVariantMap(serverConnection_->GetIdentity());
    serverConnection_->SendMessage(MSG_IDENTITY, true, true, msg);
    
    SendEvent(E_SERVERCONNECTED);
}
开发者ID:CarloMaker,项目名称:Urho3D,代码行数:13,代码来源:Network.cpp


示例12: write_scene_state

//
// write_scene_state
//
void ClientSidePrediction::write_scene_state(VectorBuffer& message, Scene* scene)
{
    // Write placeholder last input ID, which will be set per connection before sending
    message.WriteUInt(0);

    auto& nodes = scene_nodes[scene];

    // Write number of nodes
    message.WriteVLE(nodes.size());

    // Write nodes
    for (auto node : nodes)
        write_node(message, *node);
}
开发者ID:rasteron,项目名称:Urho3D-CSP,代码行数:17,代码来源:ClientSidePrediction.cpp


示例13: RefreshShaderParameterHash

void Material::RefreshShaderParameterHash()
{
    VectorBuffer temp;
    for (HashMap<StringHash, MaterialShaderParameter>::ConstIterator i = shaderParameters_.Begin(); i != shaderParameters_.End(); ++i)
    {
        temp.WriteStringHash(i->first_);
        temp.WriteVariant(i->second_.value_);
    }

    shaderParameterHash_ = 0;
    const unsigned char* data = temp.GetData();
    unsigned dataSize = temp.GetSize();
    for (unsigned i = 0; i < dataSize; ++i)
        shaderParameterHash_ = SDBMHash(shaderParameterHash_, data[i]);
}
开发者ID:Boshin,项目名称:Urho3D,代码行数:15,代码来源:Material.cpp


示例14: strncmp

bool Variant::operator ==(const VectorBuffer& rhs) const
{
    const PODVector<unsigned char>& buffer = *(reinterpret_cast<const PODVector<unsigned char>*>(&value_));
    return type_ == VAR_BUFFER && buffer.Size() == rhs.GetSize() ?
        strncmp(reinterpret_cast<const char*>(&buffer[0]), reinterpret_cast<const char*>(rhs.GetData()), buffer.Size()) == 0 :
        false;
}
开发者ID:gogoprog,项目名称:Urho3D,代码行数:7,代码来源:Variant.cpp


示例15:

PODVector<unsigned char> LuaScriptInstance::GetScriptNetworkDataAttr() const
{
    if (scriptObjectRef_ == LUA_REFNIL)
        return PODVector<unsigned char>();

    VectorBuffer buf;

    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_WRITENETWORKUPDATE];
    if (function && function->BeginCall(this))
    {
        function->PushUserType((Serializer&)buf, "Serializer");
        function->EndCall();
    }

    return buf.GetBuffer();
}
开发者ID:janfrost,项目名称:Urho3D,代码行数:16,代码来源:LuaScriptInstance.cpp


示例16: HandleSend

void Chat::HandleSend(StringHash eventType, VariantMap& eventData)
{
    String text = textEdit_->GetText();
    if (text.Empty())
        return; // Do not send an empty message
    
    Network* network = GetSubsystem<Network>();
    Connection* serverConnection = network->GetServerConnection();
    
    if (serverConnection)
    {
        // A VectorBuffer object is convenient for constructing a message to send
        VectorBuffer msg;
        msg.WriteString(text);
        // Send the chat message as in-order and reliable
        serverConnection->SendMessage(MSG_CHAT, true, true, msg);
        // Empty the text edit after sending
        textEdit_->SetText(String::EMPTY);
    }
}
开发者ID:3dicc,项目名称:Urho3D,代码行数:20,代码来源:Chat.cpp


示例17: Save

bool Node::Save(Serializer& dest) const
{
    // Write node ID
    if (!dest.WriteUInt(id_))
        return false;

    // Write attributes
    if (!Animatable::Save(dest))
        return false;

    // Write components
    dest.WriteVLE(GetNumPersistentComponents());
    for (unsigned i = 0; i < components_.Size(); ++i)
    {
        Component* component = components_[i];
        if (component->IsTemporary())
            continue;

        // Create a separate buffer to be able to skip failing components during deserialization
        VectorBuffer compBuffer;
        if (!component->Save(compBuffer))
            return false;
        dest.WriteVLE(compBuffer.GetSize());
        dest.Write(compBuffer.GetData(), compBuffer.GetSize());
    }

    // Write child nodes
    dest.WriteVLE(GetNumPersistentChildren());
    for (unsigned i = 0; i < children_.Size(); ++i)
    {
        Node* node = children_[i];
        if (node->IsTemporary())
            continue;

        if (!node->Save(dest))
            return false;
    }

    return true;
}
开发者ID:janfrost,项目名称:Urho3D,代码行数:40,代码来源:Node.cpp


示例18: SendMessage

void GameEconomicServerClientConsole::SendMessage(String Message)
{
    /// If sending message is empty
    if (Message.Empty())
    {
        return; // Do not send an empty message
    }

    /// Get connection
    Network* network = GetSubsystem<Network>();
    Connection* serverConnection = network->GetServerConnection();

    /// Send message only if serverconnection and connection is true
    if (serverConnection&&serverconnection)
    {
               // A VectorBuffer object is convenient for constructing a message to send
        VectorBuffer msg;
        msg.WriteString(Message);
        // Send the chat message as in-order and reliable
        serverConnection->SendMessage(NetMessageAdminClientSend, true, true, msg);
    }

    return;
}
开发者ID:vivienneanthony,项目名称:Urho3D-gameeconomic,代码行数:24,代码来源:GameEconomicServerClientConsole.cpp


示例19: RequestMechanicExecution

void PvPGM::RequestMechanicExecution(Node* receiver, VectorBuffer& mechanicParams)
{
	const PODVector<unsigned char>& data = mechanicParams.GetBuffer();
	MemoryBuffer msg(data);

	for (int x = 0; x < players_.Size(); x++)
	{
		if (players_[x]->player_ == receiver)
		{
			((GameMechanic*)(players_[x]))->message_ = &msg;
			((GameMechanic*)(players_[x]))->clientID_ = ((GameMechanic*)(players_[x]))->clientIDSelf_;
			((GameMechanic*)(players_[x]))->lagTime_ = 0.0f;
			players_[x]->RequestMechanicExecute();
			break;
		}
	}
}
开发者ID:practicing01,项目名称:DotsNetCrits,代码行数:17,代码来源:PvPGM.cpp


示例20: sizeof

PODVector<unsigned char> DynamicNavigationMesh::GetNavigationDataAttr() const
{
    VectorBuffer ret;
    if (navMesh_ && tileCache_)
    {
        ret.WriteBoundingBox(boundingBox_);
        ret.WriteInt(numTilesX_);
        ret.WriteInt(numTilesZ_);

        const dtNavMeshParams* params = navMesh_->getParams();
        ret.Write(params, sizeof(dtNavMeshParams));

        const dtTileCacheParams* tcParams = tileCache_->getParams();
        ret.Write(tcParams, sizeof(dtTileCacheParams));

        for (int z = 0; z < numTilesZ_; ++z)
        {
            for (int x = 0; x < numTilesX_; ++x)
            {
                dtCompressedTileRef tiles[TILECACHE_MAXLAYERS];
                const int ct = tileCache_->getTilesAt(x, z, tiles, TILECACHE_MAXLAYERS);
                for (int i = 0; i < ct; ++i)
                {
                    const dtCompressedTile* tile = tileCache_->getTileByRef(tiles[i]);
                    if (!tile || !tile->header || !tile->dataSize)
                        continue; // Don't write "void-space" tiles
                    // The header conveniently has the majority of the information required
                    ret.Write(tile->header, sizeof(dtTileCacheLayerHeader));
                    ret.WriteInt(tile->dataSize);
                    ret.Write(tile->data, tile->dataSize);
                }
            }
        }
    }
    return ret.GetBuffer();
}
开发者ID:WorldofOpenDev,项目名称:AtomicGameEngine,代码行数:36,代码来源:DynamicNavigationMesh.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ VectorDouble类代码示例发布时间:2022-05-31
下一篇:
C++ VectorBase类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap