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


C++ BitStream::StoreBits方法代码示例

本文整理汇总了C++中BitStream::StoreBits方法的典型用法代码示例。如果您正苦于以下问题:C++ BitStream::StoreBits方法的具体用法?C++ BitStream::StoreBits怎么用?C++ BitStream::StoreBits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitStream的用法示例。


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

示例1: serializeto

void serializeto(const Costume &costume,BitStream &bs,const ColorAndPartPacker *packer)
{
    bs.StorePackedBits(3,costume.m_body_type); // 0:male normal
    bs.StoreBits(32,costume.skin_color); // rgb ?

    bs.StoreFloat(costume.m_height);
    bs.StoreFloat(costume.m_physique);

    bs.StoreBits(1,costume.m_send_full_costume);
    //m_num_parts = m_parts.size();
    assert(!costume.m_parts.empty());
    bs.StorePackedBits(4,costume.m_parts.size());

    try
    {
        for(uint32_t costume_part=0; costume_part<costume.m_parts.size();costume_part++)
        {
            CostumePart part=costume.m_parts[costume_part];
            // TODO: this is bad code, it's purpose is to NOT send all part strings if m_non_default_costme_p is false
            part.m_full_part = costume.m_send_full_costume;
            ::serializeto(part,bs,packer);
        }
    }
    catch(cereal::RapidJSONException &e)
    {
        qWarning() << e.what();
    }
    catch(std::exception &e)
    {
        qCritical() << e.what();
    }
}
开发者ID:broxen,项目名称:Segs,代码行数:32,代码来源:Costume.cpp

示例2: serializeLevelsStats

void serializeLevelsStats(const Character &src,BitStream &bs, bool /*sendAbsolute*/)
{
    bs.StoreBits(1,1); // we have more data
    bs.StorePackedBits(1,0);
    bs.StorePackedBits(4,getLevel(src));
    bs.StoreBits(1,1); // we have more data
    bs.StorePackedBits(1,1);
    bs.StorePackedBits(4,getCombatLevel(src));
    bs.StoreBits(1,0); // no more data
}
开发者ID:ldilley,项目名称:Segs,代码行数:10,代码来源:Character.cpp

示例3: serializeFullStats

void serializeFullStats(const Parse_CharAttrib &src,BitStream &bs, bool /*sendAbsolute*/)
{
    bs.StoreBits(1,1); // we have more data
    bs.StorePackedBits(1,0);
    bs.StorePackedBits(7,src.m_HitPoints);
    bs.StoreBits(1,1); // we have more data
    bs.StorePackedBits(1,1);
    bs.StorePackedBits(7,src.m_Endurance);
    bs.StoreBits(1,0); // no more data
}
开发者ID:ldilley,项目名称:Segs,代码行数:10,代码来源:Character.cpp

示例4: sendClientData

void EntitiesResponse::sendClientData(BitStream &tgt) const
{
    PlayerEntity *ent=static_cast<PlayerEntity *>(m_client->char_entity());
    Character &player_char=ent->m_char;
    if(!m_incremental)
    {
        ACE_DEBUG ((LM_DEBUG,ACE_TEXT ("\tSending Character to client: full\n")));

        //full_update - > receiveCharacterFromServer
        // initial character update = level/name/class/origin/map_name
        //m_client->char_entity()->m_char.m_ent=m_client->char_entity();
        ent->serialize_full(tgt);
        player_char.sendTray(tgt);
        player_char.sendTrayMode(tgt);
        tgt.StoreString(ent->name()); // maxlength 32

        tgt.StoreString(ent->m_battle_cry); //max 128
        tgt.StoreString(ent->m_character_description); //max 1024
        player_char.sendWindows(tgt);
        tgt.StoreBits(1,0); // lfg related
        tgt.StoreBits(1,0); // a2->ent_player2->field_AC
        player_char.sendTeamBuffMode(tgt);
        player_char.sendDockMode(tgt);
        player_char.sendChatSettings(tgt);
        player_char.sendTitles(tgt);
        player_char.sendDescription(tgt);
        uint8_t auth_data[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
        tgt.StoreBitArray(auth_data,128);
        player_char.sendKeybinds(tgt);
        player_char.sendOptions(tgt);
        player_char.sendFriendList(tgt);
    }
    else
    {
        //ACE_DEBUG ((LM_DEBUG,ACE_TEXT ("\tSending Character to client: stats-only\n")));
        ent->m_char.sendFullStats(tgt);
    }
    storePowerInfoUpdate(tgt);
    //storePowerModeUpdate(tgt);
    //storeBadgeUpdate(tgt);
    //storeGenericinventoryUpdate(tgt);
    //storeInventionUpdate(tgt);
    storeTeamList(tgt);
    storeSuperStats(tgt);
    storeGroupDyn(tgt);
    bool additional=false;
    tgt.StoreBits(1,additional);
    if(additional)
    {
        tgt.StoreFloat(0.1f);
        tgt.StoreFloat(0.2f); // camera_yaw
        tgt.StoreFloat(0.3f);
    }
}
开发者ID:EnsonRedShirt,项目名称:Segs,代码行数:54,代码来源:EntitiesResponse.cpp

示例5: sendGlobalEntDebugInfo

void EntityManager::sendGlobalEntDebugInfo( BitStream &tgt ) const
{
        tgt.StoreBits(1,0); // nothing here for now
        // first while loop here
        tgt.StoreBits(1,0);
        // second while loop here
        tgt.StoreBits(1,0);
        // if here
        // players in zone and such
        tgt.StoreBits(1,0);
        // third while loop here
}
开发者ID:EnsonRedShirt,项目名称:Segs,代码行数:12,代码来源:EntityStorage.cpp

示例6: storeTeamList

void EntitiesResponse::storeTeamList(BitStream &bs) const
{
    int team_id=0; //
    NetStructure::storePackedBitsConditional(bs,20,team_id);
    //storePackedBitsConditional(bs,20,0);
    bs.StoreBits(1,0);
    bs.StoreBits(1,0);
    if(team_id>0)
    {
        bs.StoreBits(32,0);
        int num_members=0;
        bs.StorePackedBits(1,num_members);
    }
}
开发者ID:EnsonRedShirt,项目名称:Segs,代码行数:14,代码来源:EntitiesResponse.cpp

示例7: sendOwnedPowers

void Character::sendOwnedPowers(BitStream &bs) const
{
    bs.StorePackedBits(4, m_char_data.m_powersets.size()); // count
    for(const CharacterPowerSet &pset : m_char_data.m_powersets)
    {
        bs.StorePackedBits(5, pset.m_level_bought);
        bs.StorePackedBits(4, pset.m_powers.size());
        for(const CharacterPower &power : pset.m_powers)
        {
            power.m_power_info.serializeto(bs);
            bs.StorePackedBits(5, power.m_level_bought);
            bs.StoreFloat(power.getPowerTemplate().Range);

            if(power.m_total_eh_slots > power.m_enhancements.size())
                qCWarning(logPowers) << "sendOwnedPowers: Total EH Slots larger than vector!";

            bs.StorePackedBits(4, power.m_enhancements.size());
            for(const CharacterEnhancement &eh : power.m_enhancements)
            {
                bs.StoreBits(1, eh.m_slot_used); // slot has enhancement
                if(eh.m_slot_used)
                {
                    eh.m_enhance_info.serializeto(bs);
                    bs.StorePackedBits(5, eh.m_level);
                    bs.StorePackedBits(2, eh.m_num_combines);
                }
            }
        }
    }
}
开发者ID:ldilley,项目名称:Segs,代码行数:30,代码来源:Character.cpp

示例8: sendEntities

void EntityManager::sendEntities( BitStream &tgt ) const
{
        Entity *pEnt = NULL;
        std::list<Entity *>::const_iterator iter = m_entlist.begin();
        int last_idx;
        int delta;// sending delta between entities idxs ->
        assert(m_entlist.size()>0 && "Attempting to send empty entity list, the client will hang!");
        if(iter!=m_entlist.end())
        {
                pEnt = *iter;
                tgt.StorePackedBits(1,pEnt->getIdx());
                last_idx = pEnt->getIdx();
                pEnt->serializeto(tgt);
                iter++;
        }
        while(iter!=m_entlist.end())
        {
                //assert(!"Only one for now");
                pEnt = *iter;
                delta = pEnt->getIdx()-last_idx -1;
                tgt.StorePackedBits(1,delta);
                last_idx = pEnt->getIdx();
                pEnt->serializeto(tgt);
                iter++;
        }
        // last entity marker
        tgt.StorePackedBits(1,0); // next ent
        tgt.StoreBits(1,1); // create/update -> create
        tgt.StoreBits(1,1); // empty entity. will finish the receiving loop
}
开发者ID:EnsonRedShirt,项目名称:Segs,代码行数:30,代码来源:EntityStorage.cpp

示例9: serializeStats

void serializeStats(const Character &src,BitStream &bs, bool sendAbsolute)
{
    // Send CurrentAttribs
    // Send MaxAttribs
    // Send levels
    uint32_t field_idx=0;
    bs.StoreBits(1,1); // we have more data
    bs.StorePackedBits(1,field_idx++); // CurrentAttribs
    serializeStats(src.m_char_data.m_current_attribs,bs,sendAbsolute);
    bs.StoreBits(1,1); // we have more data
    bs.StorePackedBits(1,field_idx++); // MaxAttribs
    serializeStats(src.m_max_attribs,bs,sendAbsolute);
    bs.StoreBits(1,1); // we have more data
    bs.StorePackedBits(1,field_idx++); // levels
    serializeLevelsStats(src,bs,sendAbsolute);
    bs.StoreBits(1,0); // we have no more data
}
开发者ID:ldilley,项目名称:Segs,代码行数:17,代码来源:Character.cpp

示例10: storeCached_Color

void NetStructure::storeCached_Color( BitStream &bs,uint32_t col )
{
    uint32_t cache_idx=0;
    uint32_t prev_val=0;
    if(col && WorldData::instance()->colors().find_index(col,cache_idx,prev_val,false))
    {
        cache_idx+=1;
    }
    bs.StoreBits(1,(cache_idx||col==0));
    if(cache_idx||col==0)
    {
        bs.StorePackedBits(colorcachecount_bitlength,cache_idx);
    }
    else
    {
        bs.StoreBits(32,col);
    }
}
开发者ID:dragutux,项目名称:Segs,代码行数:18,代码来源:CommonNetStructures.cpp

示例11: storePowerInfoUpdate

void EntitiesResponse::storePowerInfoUpdate(BitStream &bs) const
{
    bool powerinfo_available=false;
    bs.StoreBits(1,powerinfo_available);
    if ( powerinfo_available )
    {
        bs.StoreBits(1,false);
        bs.StorePackedBits(1,0);
        // send powers
        bs.StoreBits(1,0);

        bs.StorePackedBits(4,0);
        bs.StorePackedBits(1,0);
        // ... missing
    }
    // send powers
    bs.StoreBits(1,0);
}
开发者ID:EnsonRedShirt,项目名称:Segs,代码行数:18,代码来源:EntitiesResponse.cpp

示例12: serializeto

void UpdateServer::serializeto( BitStream &tgt ) const
{
    tgt.StorePackedBits(1, 2); //opcode
    tgt.StorePackedBits(1, m_build_date);
    tgt.StorePackedBits(1, 0); // flags
    tgt.StoreString(currentVersion);
    tgt.StoreBitArray(clientInfo,sizeof(clientInfo)*8);
    tgt.StorePackedBits(1, authID);
    tgt.StoreBits(32, authCookie);
    tgt.StoreString(accountName);
}
开发者ID:nemerle,项目名称:Segs,代码行数:11,代码来源:GameEvents.cpp

示例13: storePowerModeUpdate

void EntitiesResponse::storePowerModeUpdate(BitStream &bs) const
{
    bs.StoreBits(1,0);
    if(false)
    {
        bs.StorePackedBits(3,1);
        for(int i=0; i<1; i++)
        {
            bs.StorePackedBits(3,0);
        }
    }
}
开发者ID:EnsonRedShirt,项目名称:Segs,代码行数:12,代码来源:EntitiesResponse.cpp

示例14: serialize_costumes

void Character::serialize_costumes(BitStream &bs, const ColorAndPartPacker *packer , bool send_all_costumes) const
{
    if(send_all_costumes) // This is only sent to the current player
    {
        bs.StoreBits(1, m_add_new_costume);
        if(m_add_new_costume)
        {
            bs.StoreBits(32, getCurrentCostumeIdx(*this));
            bs.StoreBits(32, uint32_t(m_costumes.size())-1); // must be minus 1 because the client adds 1
        }

        bool multiple_costumes = m_costumes.size() > 1;
        bs.StoreBits(1, multiple_costumes);
        if(multiple_costumes)
        {
            for(const Costume & c : m_costumes)
                ::serializeto(c,bs,packer);
        }
        else
            ::serializeto(m_costumes[getCurrentCostumeIdx(*this)],bs,packer);

        bs.StoreBits(1, m_char_data.m_has_sg_costume);
        if(m_char_data.m_has_sg_costume)
        {
            ::serializeto(*m_sg_costume,bs,packer);
            bs.StoreBits(1, m_char_data.m_using_sg_costume);
        }
    }
    else // other player's costumes we're sending only their current.
        ::serializeto(*getCurrentCostume(),bs,packer);
}
开发者ID:ldilley,项目名称:Segs,代码行数:31,代码来源:Character.cpp

示例15: storeTransformMatrix

void storeTransformMatrix( BitStream &tgt,const TransformStruct &src )
{
    tgt.StoreBits(1,1); // partial
    tgt.StoreBits(1,src.v1_set ? 1:0);
    tgt.StoreBits(1,src.v2_set ? 1:0);
    tgt.StoreBits(1,src.v3_set ? 1:0);
    if(src.v1_set)
    {
        for(int i=0; i<3; i++)
            storeFloatPacked(tgt,src.v1[i]);
    }
    if(src.v2_set)
    {
        for(int i=0; i<3; i++)
            storeFloatPacked(tgt,src.v2[i]);
    }
    if(src.v3_set)
    {
        for(int i=0; i<3; i++)
            storeFloatPacked(tgt,src.v3[i]);
    }
}
开发者ID:Segs,项目名称:Segs,代码行数:22,代码来源:CommonNetStructures.cpp


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