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(); } }
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); } }
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 } }
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); } } } } }
void EntitiesResponse::sendServerPhysicsPositions(BitStream &bs) const { Entity * target = m_client->char_entity(); bool full_update = true; bool has_control_id = true; bs.StoreBits(1,full_update); if( !full_update ) bs.StoreBits(1,has_control_id); fprintf(stderr,"Phys: send %d ",target->m_input_ack); if( full_update || has_control_id) bs.StoreBits(16,target->m_input_ack); //target->m_input_ack if(full_update) { bs.StoreFloat(target->pos.x); // server position bs.StoreFloat(target->pos.y); bs.StoreFloat(target->pos.z); NetStructure::storeFloatConditional(bs,0.0f); // PYR rotation ? NetStructure::storeFloatConditional(bs,0.0f); NetStructure::storeFloatConditional(bs,0.0f); } }
void SaveClientOptions::serializeto(BitStream &tgt) const { qDebug() << "Serializing to ClientOptions"; tgt.StorePackedBits(1,65); tgt.StoreFloat(data.m_mouse_speed); tgt.StoreFloat(data.m_turn_speed); tgt.StoreBits(1,data.m_mouse_invert); tgt.StoreBits(1,data.m_fade_chat_wnd); tgt.StoreBits(1,data.m_fade_nav_wnd); tgt.StoreBits(1,data.m_show_tooltips); tgt.StoreBits(1,data.m_allow_profanity); tgt.StoreBits(1,data.m_chat_balloons); tgt.StoreBits(3,data.m_show_archetype); tgt.StoreBits(3,data.m_show_supergroup); tgt.StoreBits(3,data.m_show_player_name); tgt.StoreBits(3,data.m_show_player_bars); tgt.StoreBits(3,data.m_show_enemy_name); tgt.StoreBits(3,data.m_show_enemy_bars); tgt.StoreBits(3,data.m_show_player_reticles); tgt.StoreBits(3,data.m_show_enemy_reticles); tgt.StoreBits(3,data.m_show_assist_reticles); tgt.StoreBits(5,data.m_chat_font_size); }
void storeFloatPacked( BitStream &bs,float val ) { bs.StoreBits(1,0); bs.StoreFloat(val); }
void storeFloatConditional( BitStream &bs,float val ) { bs.StoreBits(1,val!=0.0f); if(val!=0.0f) bs.StoreFloat(val); }
void storeVector( BitStream &bs,glm::vec3 &vec ) { bs.StoreFloat(vec.x); bs.StoreFloat(vec.y); bs.StoreFloat(vec.z); }
void NetStructure::storeFloatPacked( BitStream &bs,float val ) { bs.StoreBits(1,0); bs.StoreFloat(val); }
void NetStructure::storeFloatConditional( BitStream &bs,float val ) { bs.StoreBits(1,val!=0.0); if(val!=0.0) bs.StoreFloat(val); }
void NetStructure::storeVector( BitStream &bs,osg::Vec3 &vec ) { bs.StoreFloat(vec.x()); bs.StoreFloat(vec.y()); bs.StoreFloat(vec.z()); }