Пример #1
0
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
0
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
0
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
0
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
0
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
0
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
0
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
0
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
0
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
0
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
0
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
0
void CharacterSlots::serializeto( BitStream &tgt ) const
{
    tgt.StorePackedBits(1, 2); //opcode
    tgt.StorePackedBits(1,static_cast<uint32_t>(m_data->m_max_slots));
    assert(m_data->m_max_slots>0);
    for(int i=0; i<m_data->m_max_slots; i++)
    {
        Character converted;
        PlayerData player_data;
        toActualCharacter(m_data->m_characters[i],converted,player_data);
        converted.serializetoCharsel(tgt);
    }
    //tgt.StoreBitArray(m_clientinfo,128);
}
Пример #13
0
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
        }
    }
}
Пример #14
0
void EntityManager::sendDebuggedEntities( BitStream &tgt ) const
{
        tgt.StorePackedBits(10,0); // index of debugged entity
        return ;
        //Send debug info

}
Пример #15
0
void Costume::storeCharselParts( BitStream &bs ) const
{
    bs.StorePackedBits(1,m_parts.size());
    for(const CostumePart & part : m_parts)
    {
        serializeto_charsel(part,bs);
    }
}
Пример #16
0
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
}
Пример #17
0
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);
                }
            }
        }
    }
}
Пример #18
0
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);
}
Пример #19
0
void CharacterResponse::serializeto( BitStream &bs ) const
{
    GameAccountResponseCharacterData indexed_character(m_data->get_character(m_index));
    Character converted;
    PlayerData player_data;
    toActualCharacter(indexed_character,converted,player_data);
    bs.StorePackedBits(1,6); // opcode

    if(indexed_character.m_name.compare("EMPTY")!=0)// actual character was read from db
    {
        bs.StorePackedBits(1,m_index);
        converted.getCurrentCostume()->storeCharselParts(bs);
    }
    else
    {
        bs.StorePackedBits(1,-1);
        bs.StorePackedBits(1,0); // 0 parts
    }
}
Пример #20
0
void Character::serializetoCharsel( BitStream &bs, const QString& entity_map_name )
{
    Character c = *this;
    bs.StorePackedBits(1,getLevel(c));
    bs.StoreString(getName());
    bs.StoreString(getClass(c));
    bs.StoreString(getOrigin(c));

    if(m_costumes.empty())
    {
        assert(m_name.compare(EMPTY_STRING)==0); // only empty characters can have no costumes
        Costume::NullCostume.storeCharsel(bs);
    }
    else
        getCurrentCostume()->storeCharsel(bs);

    bs.StoreString(entity_map_name);
    bs.StorePackedBits(1,1); // field_1CC
}
Пример #21
0
void CharacterResponse::serializeto( BitStream &bs ) const
{
    Character *indexed_character = m_client->getCharacter(m_index);
    CharacterCostume *c=0;
    assert(indexed_character);
    if(indexed_character->getName().compare("EMPTY")!=0) // actual character was read from db
        c=static_cast<CharacterCostume *>(indexed_character->getCurrentCostume());
    bs.StorePackedBits(1,6); // opcode

    if(c)
    {
        bs.StorePackedBits(1,m_index);
        c->storeCharselParts(bs);
    }
    else
    {
        bs.StorePackedBits(1,-1);
        bs.StorePackedBits(1,0); // 0 parts
    }
}
Пример #22
0
void NetStructure::storeCached_String( BitStream &bs,const std::string & str )
{
    uint32_t cache_idx=0;
    uint32_t prev_val=0;
    if(str.size() && WorldData::instance()->strings().find_index(str,cache_idx,prev_val,false))
    {
        cache_idx+=1;
    }
    bs.StoreBits(1,(cache_idx||str.size()==0));
    if(cache_idx||str.size()==0)
        bs.StorePackedBits(stringcachecount_bitlength,cache_idx);
    else
        bs.StoreString(str);
}
Пример #23
0
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);
    }
}
Пример #24
0
void EntitiesResponse::serializeto_internal( BitStream &tgt ) const
{
    EntityManager &ent_manager=m_client->current_map()->m_entities;


    tgt.StorePackedBits(1,m_incremental ? 2 : 3); // opcode  3 - full update.

    tgt.StoreBits(1,entReceiveUpdate); // passed to Entity::EntReceive as a parameter

    sendCommands(tgt);

    tgt.StoreBits(32,abs_time);
    //tgt.StoreBits(32,db_time);

    tgt.StoreBits(1,unkn2);
    if(unkn2)
    {
        //g_debug_info 0
        //interpolation level 2
        //g_bitcount_rel 1
    }
    else
    {
        tgt.StoreBits(1,debug_info);
        tgt.StoreBits(1,m_interpolating);
        if(m_interpolating==1)
        {
            tgt.StoreBits(2,m_interpolation_level);
            tgt.StoreBits(2,m_interpolation_bits);
        }
    }

    //else debug_info = false;
    ent_manager.sendEntities(tgt);
    if(debug_info&&!unkn2)
    {
        ent_manager.sendDebuggedEntities(tgt); // while loop, sending entity id's and debug info for each
        ent_manager.sendGlobalEntDebugInfo(tgt);
    }
    sendServerPhysicsPositions(tgt); // These are not client specific ?
    sendControlState(tgt);// These are not client specific ?
    ent_manager.sendDeletes(tgt);
    // Client specific part
    sendClientData(tgt);
    //FIXME: Most Server messages must follow entity update.
}
Пример #25
0
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);
    }
}
Пример #26
0
void Character::sendInspirations(BitStream &bs) const
{
    int max_cols = m_char_data.m_max_insp_cols;
    int max_rows = m_char_data.m_max_insp_rows;

    bs.StorePackedBits(3, max_cols); // count
    bs.StorePackedBits(3, max_rows); // count

    for(int col = 0; col < max_cols; ++col)
    {
        for(int row = 0; row < max_rows; ++row)
        {
            bs.StoreBits(1, m_char_data.m_inspirations.value(col, row).m_has_insp);

            if(m_char_data.m_inspirations.value(col, row).m_has_insp)
                m_char_data.m_inspirations.value(col, row).m_insp_info.serializeto(bs);
        }
    }
}
Пример #27
0
void Character::SendCharBuildInfo(BitStream &bs) const
{
    Character c = *this;
    bs.StoreString(getClass(c));   // class name
    bs.StoreString(getOrigin(c));  // origin name
    bs.StorePackedBits(5, getLevel(c)); // plevel is level
    PUTDEBUG("SendCharBuildInfo after plevel");

    // Owned Powers
    sendOwnedPowers(bs);
    PUTDEBUG("SendCharBuildInfo after powers");

    // Inspirations
    sendInspirations(bs);
    PUTDEBUG("SendCharBuildInfo after inspirations");

    // Enhancements
    sendEnhancements(bs);
    PUTDEBUG("SendCharBuildInfo after boosts");
}
Пример #28
0
void serializeFullStats(const Character &src,BitStream &bs, bool sendAbsolute)
{
    uint32_t field_idx=0;
    bs.StoreBits(1,1); // we have more data
    bs.StorePackedBits(1,field_idx++); // first field is CurrentAttribs
    serializeFullStats(src.m_char_data.m_current_attribs,bs,sendAbsolute);
    bs.StoreBits(1,1); // we have more data
    bs.StorePackedBits(1,field_idx++); // first field is MaxAttribs
    serializeFullStats(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,1); // we have more data
    bs.StorePackedBits(1,field_idx++); // ExperiencePoints
    bs.StorePackedBits(16,getXP(src));
    bs.StoreBits(1,1); // we have more data
    bs.StorePackedBits(1,field_idx++); // ExperienceDebt
    bs.StorePackedBits(16,getDebt(src));
    bs.StoreBits(1,1); // we have more data
    bs.StorePackedBits(1,field_idx++); // Influence
    bs.StorePackedBits(16,getInf(src));

    bs.StoreBits(1,0); // we have no more data
}
Пример #29
0
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);
}
Пример #30
0
void Character::sendFriendList(BitStream &bs) const
{
    const FriendsList *fl(&m_char_data.m_friendlist);
    bs.StorePackedBits(1,1); // v2 = force_update
    bs.StorePackedBits(1,fl->m_friends_count);

    for(int i=0; i<fl->m_friends_count; ++i)
    {
        bs.StoreBits(1,fl->m_has_friends); // if false, client will skip this iteration
        bs.StorePackedBits(1,fl->m_friends[i].m_db_id);
        bs.StoreBits(1,fl->m_friends[i].m_online_status);
        bs.StoreString(fl->m_friends[i].m_name);
        bs.StorePackedBits(1,fl->m_friends[i].m_class_idx);
        bs.StorePackedBits(1,fl->m_friends[i].m_origin_idx);

        if(!fl->m_friends[i].m_online_status)
            continue; // if friend is offline, the rest is skipped

        bs.StorePackedBits(1,fl->m_friends[i].m_map_idx);
        bs.StoreString(fl->m_friends[i].m_mapname);
    }
}