本文整理汇总了C++中BitStream::GetPackedBits方法的典型用法代码示例。如果您正苦于以下问题:C++ BitStream::GetPackedBits方法的具体用法?C++ BitStream::GetPackedBits怎么用?C++ BitStream::GetPackedBits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitStream
的用法示例。
在下文中一共展示了BitStream::GetPackedBits方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serializefrom
void serializefrom(Costume &tgt, BitStream &src,const ColorAndPartPacker *packer)
{
tgt.m_body_type = src.GetPackedBits(3); // 0:male normal
tgt.skin_color = src.GetBits(32); // rgb
tgt.m_height = src.GetFloat();
tgt.m_physique = src.GetFloat();
tgt.m_send_full_costume = src.GetBits(1);
tgt.m_num_parts = src.GetPackedBits(4);
try
{
for(int costume_part=0; costume_part<tgt.m_num_parts;costume_part++)
{
CostumePart part;
part.m_full_part = tgt.m_send_full_costume;
::serializefrom(part,src,packer);
tgt.m_parts.push_back(part);
}
}
catch(cereal::RapidJSONException &e)
{
qWarning() << e.what();
}
catch(std::exception &e)
{
qCritical() << e.what();
}
}
示例2: recv_client_opts
//TODO: use generic ReadableStructures here ?
void RecvInputState::recv_client_opts(BitStream &bs)
{
ClientOptions opts;
ClientOption *entry;
glm::vec3 vec;
int cmd_idx;
while((cmd_idx = bs.GetPackedBits(1))!=0)
{
entry=opts.get(cmd_idx-1);
if (!entry)
{
qWarning() << "recv_client_opts missing opt for cmd index" << cmd_idx-1;
continue;
}
for(ClientOption::Arg &arg : entry->m_args)
{
switch ( arg.type )
{
case ClientOption::t_int:
{
*((int32_t *)arg.tgt) = bs.GetPackedBits(1);
break;
}
case ClientOption::t_float:
{
*((float *)arg.tgt)=bs.GetFloat();
break;
}
case ClientOption::t_quant_angle:
{
float * tgt_angle = (float *)arg.tgt;
*tgt_angle = AngleDequantize(bs.GetBits(14),14);
qCDebug(logInput, "Quant angle res:%f", *tgt_angle); //dequantized angle
break;
}
case ClientOption::t_string:
case ClientOption::t_sentence:
{
QString v;
bs.GetString(v);
break;
}
case ClientOption::t_vec3:
{
for (int j = 0; j < 3; ++j )
{
vec[j] = bs.GetFloat();
}
break;
}
default:
continue;
}
}
}
}
示例3: serializefrom
void UpdateServer::serializefrom( BitStream &src )
{
m_build_date = src.GetPackedBits(1);
/*uint32_t t =*/ src.GetPackedBits(1);
src.GetString(currentVersion);
src.GetBitArray(clientInfo,sizeof(clientInfo)*8);
authID = src.GetPackedBits(1);
authCookie = src.GetBits(32);
src.GetString(accountName);
}
示例4: recv_client_opts
//TODO: use generic ReadableStructures here ?
void InputState::recv_client_opts(BitStream &bs)
{
ClientOptions opts;
ClientOption *entry;
int opt_idx=0;
int some_idx = bs.GetPackedBits(1);
entry=opts.get(opt_idx)-1;
Vector3 vec;
while(some_idx!=0)
{
for(size_t i=0; i<entry->m_args.size(); i++)
{
ClientOption::Arg &arg=entry->m_args[i];
switch ( arg.type )
{
case ClientOption::t_int:
{
*((int32_t *)arg.tgt) = bs.GetPackedBits(1);
break;
}
case ClientOption::t_float:
{
*((float *)arg.tgt)=bs.GetFloat();
break;
}
case ClientOption::t_quant_angle:
{
printf("Quant:%d\n",bs.GetBits(14)); //quantized angle
break;
}
case ClientOption::t_string:
case 4:
{
std::string v;
bs.GetString(v);
break;
}
case ClientOption::t_vec3:
{
for (int j = 0; j < 3; ++j )
{
vec.v[j] = bs.GetFloat();
}
break;
}
default:
continue;
}
}
some_idx = bs.GetPackedBits(1)-1;
opt_idx++;
entry=opts.get(opt_idx);
}
}
示例5: getPackedBitsConditional
int NetStructure::getPackedBitsConditional( BitStream &bs,int numbits )
{
if(bs.GetBits(1))
{
return bs.GetPackedBits(numbits);
}
return 0;
}
示例6: getPackedBitsConditional
int getPackedBitsConditional( BitStream &bs,uint8_t numbits )
{
if(bs.GetBits(1))
{
return bs.GetPackedBits(numbits);
}
return 0;
}
示例7: serializefrom
void NewEntity::serializefrom( BitStream &bs )
{
// the very first time an entity is created (character creation)
m_cookie = bs.GetPackedBits(1);
//m_city_of_developers = src.GetBits(1);
m_new_character=bs.GetBits(1);
if(m_new_character)
{
m_character_data.appendBitStream(bs);
}
}
示例8: serializefrom
int NetCommand::serializefrom( BitStream &bs )
{
for(size_t i=0; i<m_arguments.size(); i++)
{
switch(m_arguments[i].type)
{
case 1:
{
int res=bs.GetPackedBits(1);
if(m_arguments[i].targetvar)
*((int *)m_arguments[i].targetvar) = res;
qDebug("CommRecv %s:arg%zu : %d", qPrintable(m_name),i,res);
break;
}
case 2:
case 4:
{
QString res;
bs.GetString(res); // postprocessed
qDebug("CommRecv %s:arg%zu : %s", qPrintable(m_name),i,qPrintable(res));
break;
}
case 3:
{
float res = bs.GetFloat();
qDebug("CommRecv %s:arg%zu : %f", qPrintable(m_name),i,res);
break;
}
case 5:
{
float res1 = normalizedCircumferenceToFloat(bs.GetBits(14),14);
qDebug("CommRecv %s:arg%zu : %f", qPrintable(m_name),i,res1);
break;
}
case 6:
break;
case 7:
{
float res1 = bs.GetFloat();
float res2 = bs.GetFloat();
float res3 = bs.GetFloat();
qDebug("CommRecv %s:arg%zu : %f,%f,%f", qPrintable(m_name),i,res1,res2,res3);
break;
}
}
}
return 1;
}
示例9: serializefrom_delta
// recover actual ControlState from network data and previous entry
void serializefrom_delta(BitStream &bs,const ControlState &prev)
{
field0 = bs.GetPackedBits(1); // field_0 diff next-current
time_res = bs.GetPackedBits(1); // time to next state ?
timestep = bs.GetFloat(); // next state's timestep
time_rel1C = timestep;
if(bs.GetBits(1)) //timestep!=time_rel1C
time_rel1C = bs.GetFloat();
m_perf_cntr_diff = bs.Get64Bits(); //next_state->ticks - current_state->ticks
if(bs.GetBits(1))
{
// perf freq changed between current and next
m_perf_freq_diff = bs.Get64Bits();
}
}
示例10: getCached_String
std::string NetStructure::getCached_String( BitStream &bs )
{
std::ostringstream strm;
std::string tgt("");
bool in_cache= bs.GetBits(1);
if(in_cache)
{
int in_cache_idx = bs.GetPackedBits(stringcachecount_bitlength);
std::string *kv = WorldData::instance()->strings().key_for_idx(in_cache_idx);
if(kv)
tgt=*kv;
return tgt;
}
else
bs.GetString(tgt);
return tgt;
}
示例11: serializefrom
void RecvInputState::serializefrom(BitStream &bs)
{
m_next_state.m_full_timeupdate = false; // possibly some kind of full_update flag that is used elsewhere also
if(bs.GetBits(1))
extended_input(bs);
m_next_state.m_has_target = bs.GetBits(1);
m_next_state.m_target_idx = bs.GetPackedBits(14); // targeted entity server_index
qCDebug(logTarget, "Has Target? %d | TargetIdx: %d", m_next_state.m_has_target, m_next_state.m_target_idx);
TimeState prev_fld;
int ctrl_idx = 0;
while(bs.GetBits(1)) // receive control state array entries ?
{
TimeState fld;
if(ctrl_idx)
{
fld.serializefrom_delta(bs, prev_fld);
}
else // initial values
{
fld.serializefrom_base(bs);
}
fld.dump();
prev_fld = fld;
ctrl_idx++;
}
recv_client_opts(bs); // g_pak contents will follow
if(bs.GetReadableBits()>0)
{
m_user_commands.ResetOffsets();
bs.ByteAlign(true,false);
m_user_commands.StoreBitArray(bs.read_ptr(),bs.GetReadableBits());
// all remaining bits were moved to m_user_commands.
bs.SetReadPos(bs.GetWritePos());
}
}
示例12: serializefrom
void SaveClientOptions::serializefrom(BitStream & bs)
{
qDebug() << "Serializing options from Client";
data.m_mouse_speed = bs.GetFloat();
data.m_turn_speed = bs.GetFloat();
data.m_mouse_invert = bs.GetBits(1);
data.m_fade_chat_wnd = bs.GetBits(1);
data.m_fade_nav_wnd = bs.GetBits(1);
data.m_show_tooltips = bs.GetBits(1);
data.m_allow_profanity = bs.GetBits(1);
data.m_chat_balloons = bs.GetBits(1);
data.m_show_archetype = (ReticleVisibility)bs.GetBits(3);
data.m_show_supergroup = (ReticleVisibility)bs.GetBits(3);
data.m_show_player_name = (ReticleVisibility)bs.GetBits(3);
data.m_show_player_bars = (ReticleVisibility)bs.GetBits(3);
data.m_show_enemy_name = (ReticleVisibility)bs.GetBits(3);
data.m_show_enemy_bars = (ReticleVisibility)bs.GetBits(3);
data.m_show_player_reticles = (ReticleVisibility)bs.GetBits(3);
data.m_show_enemy_reticles = (ReticleVisibility)bs.GetBits(3);
data.m_show_assist_reticles = (ReticleVisibility)bs.GetBits(3);
data.m_chat_font_size = bs.GetPackedBits(5);
}
示例13: serializefrom
void InputState::serializefrom(BitStream &bs)
{
m_send_deltas=false;
#ifdef DEBUG_INPUT
fprintf(stderr,"\nI:");
#endif
if(bs.GetBits(1))
extended_input(bs);
bool has_targeted_entity = bs.GetBits(1);
int tgt_idx=bs.GetPackedBits(14); // targeted entity server index
int ctrl_idx=0;
#ifdef DEBUG_INPUT
fprintf(stderr,"T:[%d]",has_targeted_entity);
if(has_targeted_entity)
fprintf(stderr,"TI:[%d]",tgt_idx);
#endif
ControlState prev_fld;
while(bs.GetBits(1)) // receive control state array entries ?
{
ControlState fld;
if(ctrl_idx)
{
fld.serializefrom_delta(bs,prev_fld);
}
else // initial values
{
fld.serializefrom_base(bs);
}
fld.dump();
prev_fld = fld;
ctrl_idx++;
}
recv_client_opts(bs); // g_pak contents will follow
#ifdef DEBUG_INPUT
fprintf(stderr,"\n");
#endif
}
示例14: serializefrom
void TradeWasUpdatedMessage::serializefrom(BitStream& bs)
{
m_info.m_db_id = static_cast<uint32_t>(bs.GetPackedBits(1));
m_info.m_accepted = bs.GetPackedBits(1);
m_info.m_influence = static_cast<uint32_t>(bs.GetPackedBits(1));
const int num_enhs = bs.GetPackedBits(1);
const int num_insp = bs.GetPackedBits(1);
for (int i = 0; i < num_enhs; ++i)
{
const uint32_t idx = static_cast<uint32_t>(bs.GetPackedBits(1));
m_info.m_enhancements.push_back(idx);
}
for (int i = 0; i < num_insp; ++i)
{
const uint32_t col = static_cast<uint32_t>(bs.GetPackedBits(1));
const uint32_t row = static_cast<uint32_t>(bs.GetPackedBits(1));
m_info.m_inspirations.push_back(TradeInspiration(col, row));
}
}
示例15: switch
void InputState::partial_2(BitStream &bs)
{
uint8_t control_id;
//uint16_t v6;
uint16_t time_since_prev;
int v;
static const char *control_name[] = {"FORWARD",
"BACK",
"LEFT",
"RIGHT",
"UP",
"DOWN"};
do
{
if(bs.GetBits(1))
control_id = 8;
else
control_id = bs.GetBits(4);
if(bs.GetBits(1)) //
time_since_prev=bs.GetBits(2)+32;
else
time_since_prev=bs.GetBits(m_csc_deltabits);
switch(control_id)
{
case 0: case 1:
case 2: case 3:
case 4: case 5:
fprintf(stderr,"%s : %d - ",control_name[control_id],time_since_prev);
processDirectionControl(control_id,time_since_prev,bs.GetBits(1));
break;
case 6:
case 7:
{
v = bs.GetBits(11);
// v = (x+pi)*(2048/2pi)
// x = (v*(pi/1024))-pi
float recovered = (float(v)/2048.0f)*(2*M_PI) - M_PI;
if(control_id==6) //TODO: use camera_pyr.v[] here ?
camera_pyr.x = recovered;
else
camera_pyr.y = recovered;
fprintf(stderr,"Pyr %f : %f \n",camera_pyr.x,camera_pyr.y);
break;
}
case 8:
v = bs.GetBits(1);
fprintf(stderr," C8[%d] ",v);
if ( m_send_deltas )
{
m_t1=bs.GetPackedBits(8);
m_t2=bs.GetPackedBits(8);
}
else
{
m_send_deltas = true;
m_t1=bs.GetBits(32);
m_t2=bs.GetPackedBits(10);
}
fprintf(stderr,"t1:t2 [%d,%d] ",m_t1,m_t2);
if(bs.GetBits(1))
{
v=bs.GetBits(8);
fprintf(stderr,"v [%d] ",v);
}
break;
case 9:
//a2->timerel_18
//fprintf(stderr,"CtrlId %d : %d - ",control_id,time_since_prev);
fprintf(stderr,"C9:%d ",bs.GetBits(8));
break;
case 10:
fprintf(stderr,"C10 : %d - ",time_since_prev);
fprintf(stderr,"%d\n",bs.GetBits(1)); //a2->timerel_18 & 1
break;
default:
assert(!"Unknown control_id");
}
} while(bs.GetBits(1));
}