Ejemplo n.º 1
0
        override protected void BytesToData(byte[] data)
        {
            if (data == null || data.Length < 3)
            {
                return;
            }

            short num = IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, 0));

            LoginCharacter[] cs = new LoginCharacter[num];

            int i      = 0;
            int offset = 2;

            for (; i < num; i++)
            {
                cs[i]    = new LoginCharacter();
                cs[i].ID = NetConvert.ToUInt32(IPAddress.NetworkToHostOrder(BitConverter.ToInt32(data, offset)));
                offset  += 4;
            }
            num     = IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, offset));
            offset += 2;
            for (i = 0; i < num; i++)
            {
                NetString s = new NetString(data, offset);
                cs[i].Name = s.ToString();
                offset    += s.TotalLength;
            }
            num     = IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, offset));
            offset += 2;
            for (i = 0; i < num; i++)
            {
                cs[i].Level = IPAddress.NetworkToHostOrder(BitConverter.ToInt32(data, offset));
                offset     += 4;
            }
            num     = IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, offset));
            offset += 2;
            for (i = 0; i < num; i++)
            {
                cs[i].IsOnline = Convert.ToBoolean(IPAddress.NetworkToHostOrder(BitConverter.ToInt32(data, offset)));
                offset        += 4;
            }

            this._characters      = cs;
            this._charactersCount = num;
        }