コード例 #1
0
    static void CL_ParseClientdata(int bits)
    {
        if ((bits & q_shared.SU_VIEWHEIGHT) != 0)
        {
            cl.viewheight = Reader.MSG_ReadChar();
        }
        else
        {
            cl.viewheight = q_shared.DEFAULT_VIEWHEIGHT;
        }

        if ((bits & q_shared.SU_IDEALPITCH) != 0)
        {
            cl.idealpitch = Reader.MSG_ReadChar();
        }
        else
        {
            cl.idealpitch = 0;
        }

        cl.mvelocity[1] = cl.mvelocity[0];
        for (int i = 0; i < 3; i++)
        {
            if ((bits & (q_shared.SU_PUNCH1 << i)) != 0)
            {
                Mathlib.SetComp(ref cl.punchangle, i, Reader.MSG_ReadChar());
            }
            else
            {
                Mathlib.SetComp(ref cl.punchangle, i, 0);
            }
            if ((bits & (q_shared.SU_VELOCITY1 << i)) != 0)
            {
                Mathlib.SetComp(ref cl.mvelocity[0], i, Reader.MSG_ReadChar() * 16);
            }
            else
            {
                Mathlib.SetComp(ref cl.mvelocity[0], i, 0);
            }
        }

        // [always sent]	if (bits & SU_ITEMS)
        int i2 = Reader.MSG_ReadLong();

        if (cl.items != i2)
        {       // set flash times
            Sbar_Changed();
            for (int j = 0; j < 32; j++)
            {
                if ((i2 & (1 << j)) != 0 && (cl.items & (1 << j)) == 0)
                {
                    cl.item_gettime[j] = (float)cl.time;
                }
            }
            cl.items = i2;
        }

        cl.onground = (bits & q_shared.SU_ONGROUND) != 0;
        cl.inwater  = (bits & q_shared.SU_INWATER) != 0;

        if ((bits & q_shared.SU_WEAPONFRAME) != 0)
        {
            cl.stats[q_shared.STAT_WEAPONFRAME] = Reader.MSG_ReadByte();
        }
        else
        {
            cl.stats[q_shared.STAT_WEAPONFRAME] = 0;
        }

        if ((bits & q_shared.SU_ARMOR) != 0)
        {
            i2 = Reader.MSG_ReadByte();
        }
        else
        {
            i2 = 0;
        }
        if (cl.stats[q_shared.STAT_ARMOR] != i2)
        {
            cl.stats[q_shared.STAT_ARMOR] = i2;
            Sbar_Changed();
        }

        if ((bits & q_shared.SU_WEAPON) != 0)
        {
            i2 = Reader.MSG_ReadByte();
        }
        else
        {
            i2 = 0;
        }
        if (cl.stats[q_shared.STAT_WEAPON] != i2)
        {
            cl.stats[q_shared.STAT_WEAPON] = i2;
            Sbar_Changed();
        }

        i2 = Reader.MSG_ReadShort();
        if (cl.stats[q_shared.STAT_HEALTH] != i2)
        {
            cl.stats[q_shared.STAT_HEALTH] = i2;
            Sbar_Changed();
        }

        i2 = Reader.MSG_ReadByte();
        if (cl.stats[q_shared.STAT_AMMO] != i2)
        {
            cl.stats[q_shared.STAT_AMMO] = i2;
            Sbar_Changed();
        }

        for (i2 = 0; i2 < 4; i2++)
        {
            int j = Reader.MSG_ReadByte();
            if (cl.stats[q_shared.STAT_SHELLS + i2] != j)
            {
                cl.stats[q_shared.STAT_SHELLS + i2] = j;
                Sbar_Changed();
            }
        }

        i2 = Reader.MSG_ReadByte();

        if (_GameKind == GameKind.StandardQuake)
        {
            if (cl.stats[q_shared.STAT_ACTIVEWEAPON] != i2)
            {
                cl.stats[q_shared.STAT_ACTIVEWEAPON] = i2;
                Sbar_Changed();
            }
        }
        else
        {
            if (cl.stats[q_shared.STAT_ACTIVEWEAPON] != (1 << i2))
            {
                cl.stats[q_shared.STAT_ACTIVEWEAPON] = (1 << i2);
                Sbar_Changed();
            }
        }
    }