Ejemplo n.º 1
0
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();
    }
}
Ejemplo n.º 2
0
//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;
            }
        }
    }
}
Ejemplo n.º 3
0
//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);
    }
}
Ejemplo n.º 4
0
    void serializefrom_base(BitStream &bs)
    {
        field0   = bs.GetBits(32); //field_0
        time_res = bs.GetBits(32); // get_time_resl
        timestep = bs.GetFloat(); //v7->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
        m_perf_cntr_diff = bs.Get64Bits(); //v7->perf_cntr1
    }
Ejemplo n.º 5
0
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;
}
Ejemplo n.º 6
0
    // 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();
        }
    }
Ejemplo n.º 7
0
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);
}