Lidgren.Network.NetBuffer.ReadInt16 C# (CSharp) Method

ReadInt16() public method

Reads a 16 bit signed integer written using Write(Int16)
public ReadInt16 ( ) : Int16
return System.Int16
        public Int16 ReadInt16()
        {
            NetException.Assert(m_bitLength - m_readPosition >= 16, c_readOverflowError);
            uint retval = NetBitWriter.ReadUInt16(m_data, 16, m_readPosition);
            m_readPosition += 16;
            return (short)retval;
        }

Usage Example

Ejemplo n.º 1
0
        void ParseGameState(NetBuffer msg)
        {
            clc.connectPacketCount = 0;
            // wipe local client state
            ClearState();
            // a gamestate always marks a server command sequence
            clc.serverCommandSequence = msg.ReadInt32();
            // parse all the configstrings and baselines
            while (true)
            {
                int cmd = msg.ReadByte();

                if (cmd == (int)svc_ops_e.svc_EOF)
                    break;

                if (cmd == (int)svc_ops_e.svc_configstring)
                {
                    int index = msg.ReadInt16();
                    string s = msg.ReadString();
                    cl.gamestate.data.Add(index, s);
                }
                else if (cmd == (int)svc_ops_e.svc_baseline)
                {
                    int newnum = msg.ReadInt32();
                    if (newnum < 0 || newnum >= 1024)
                    {
                        Common.Instance.Error("ParseGameState: Baseline number out of range: " + newnum);
                    }
                    Common.entityState_t nullstate = new Common.entityState_t();
                    Net.Instance.MSG_ReadDeltaEntity(msg, ref nullstate, ref cl.entityBaselines[newnum], newnum);
                }
                else
                {
                    Common.Instance.Error("ParseGameState: bad command byte");
                }
            }

            clc.clientNum = msg.ReadInt32();

            // parse useful values out of CS_SERVERINFO
            //ParseServerInfo();

            // parse serverId and other cvars
            SystemInfoChanged();

            InitDownloads();
        }
All Usage Examples Of Lidgren.Network.NetBuffer::ReadInt16