本文整理汇总了C++中BitStream::StorePackedBits方法的典型用法代码示例。如果您正苦于以下问题:C++ BitStream::StorePackedBits方法的具体用法?C++ BitStream::StorePackedBits怎么用?C++ BitStream::StorePackedBits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitStream
的用法示例。
在下文中一共展示了BitStream::StorePackedBits方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
}
示例2: serializeto
void PreUpdateCommand::serializeto(BitStream &bs) const
{
bs.StorePackedBits(1, 13);
for(const auto &command : m_contents)
command->serializeto(bs);
bs.StorePackedBits(1,0); // finalize the command list
}
示例3: 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();
}
}
示例4: serializeto
void NetCommandManager::serializeto(BitStream &tgt, const vNetCommand &commands)
{
for(uint32_t i=0; i<commands.size(); i++)
{
tgt.StorePackedBits(1,i+1);
tgt.StoreString(commands[i]->m_name);
}
tgt.StorePackedBits(1,~0u); // end of command list
}
示例5: 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
}
示例6: sendDeletes
void EntityManager::sendDeletes( BitStream &tgt ) const
{
int num_to_remove=0;
tgt.StorePackedBits(1,num_to_remove);
for(int i=0; i<num_to_remove; i++)
{
tgt.StorePackedBits(1,0);//index
tgt.StorePackedBits(1,0);//
}
}
示例7: 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
}
示例8: serializeto
void CharacterSlots::serializeto( BitStream &tgt ) const
{
tgt.StorePackedBits(1, 2); //opcode
tgt.StorePackedBits(1,static_cast<uint32_t>(m_client->max_slots()));
assert(m_client->max_slots()>0);
for(size_t i=0; i<m_client->max_slots(); i++)
{
m_client->getCharacter(i)->serializetoCharsel(tgt);
}
//tgt.StoreBitArray(m_clientinfo,128);
}
示例9: sendServerControlState
void EntitiesResponse::sendServerControlState(BitStream &bs) const
{
Vector3 spd(1,80,1);
Vector3 zeroes;
bool m_flying=false;
bool m_dazed=false;
// user entity
Entity *ent = m_client->char_entity();
CscCommon_Sub28 struct_csc;
memset(&struct_csc,0,sizeof(struct_csc));
static int vla=1;
int g=rand()&0xff;
for(int i=0; i<3; ++i)
struct_csc.a.v[i] = g+vla;
vla+=1;
struct_csc.b.max_speed = struct_csc.a.max_speed = 5.0f;
struct_csc.b.gravitational_constant = struct_csc.a.gravitational_constant = 3.0f;
// for(int i=3; i<5; ++i)
// struct_csc.a.v[i] = rand()&0xf;
bool update_part_1=true;
bool update_part_2=false;
bs.StoreBits(1,update_part_1);
if(update_part_1)
{
//rand()&0xFF
bs.StoreBits(8,vla); // value stored in control state field_134
// after input_send_time_initialized, this value is enqueued as CSC_9's control_flags
// This is entity speed vector !!
NetStructure::storeVector(bs,spd);
bs.StoreFloat(1.0f); // speed rel back
bs.StoreBitArray((uint8_t *)&struct_csc,sizeof(CscCommon_Sub28)*8);
bs.StoreFloat(0.1f);
bs.StoreBits(1,m_flying); // key push bits ??
bs.StoreBits(1,m_dazed); // key push bits ??
bs.StoreBits(1,0); // key push bits ??
bs.StoreBits(1,0); // key push bits ??
bs.StoreBits(1,0); // key push bits ??
bs.StoreBits(1,0); // key push bits ??
}
// Used to force the client to a position/speed/pitch/rotation by server
bs.StoreBits(1,update_part_2);
if(update_part_2)
{
bs.StorePackedBits(1,0); // sets g_client_pos_id_rel
NetStructure::storeVector(bs,spd);
NetStructure::storeVectorConditional(bs,zeroes); // vector3 -> speed ? likely
NetStructure::storeFloatConditional(bs,0); // Pitch not used ?
NetStructure::storeFloatConditional(bs,ent->inp_state.pyr.x); // Pitch
NetStructure::storeFloatConditional(bs,0); // Roll
bs.StorePackedBits(1,0); // sets the lowest bit in CscCommon::flags
}
}
示例10: 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);
}
示例11: 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);
}
}
}
示例12: sendEnhancements
void Character::sendEnhancements(BitStream &bs) const
{
bs.StorePackedBits(5, m_char_data.m_enhancements.size()); // count
for(size_t i = 0; i < m_char_data.m_enhancements.size(); ++i)
{
bs.StorePackedBits(3, m_char_data.m_enhancements[i].m_slot_idx); // boost idx, maybe use m_enhancement_idx
bs.StoreBits(1, m_char_data.m_enhancements[i].m_slot_used); // 1 set, 0 clear
if(m_char_data.m_enhancements[i].m_slot_used)
{
m_char_data.m_enhancements[i].m_enhance_info.serializeto(bs);
bs.StorePackedBits(5, m_char_data.m_enhancements[i].m_level); // boost idx
bs.StorePackedBits(2, m_char_data.m_enhancements[i].m_num_combines); // boost idx
}
}
}
示例13: sendDebuggedEntities
void EntityManager::sendDebuggedEntities( BitStream &tgt ) const
{
tgt.StorePackedBits(10,0); // index of debugged entity
return ;
//Send debug info
}
示例14: storeCharselParts
void Costume::storeCharselParts( BitStream &bs ) const
{
bs.StorePackedBits(1,m_parts.size());
for(const CostumePart & part : m_parts)
{
serializeto_charsel(part,bs);
}
}
示例15: 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
}