Ejemplo n.º 1
0
    public static Role_DataProto GetProto(byte[] buffer, bool isChild = false)
    {
        Role_DataProto proto = new Role_DataProto();

        MMO_MemoryStream ms = null;

        if (!isChild)
        {
            ms = GameEntry.Socket.SocketSendMS;
        }
        else
        {
            ms = GameEntry.Pool.DequeueClassObject <MMO_MemoryStream>();
        }
        ms.SetLength(0);
        ms.Write(buffer, 0, buffer.Length);
        ms.Position = 0;

        proto.RoleId   = ms.ReadInt();
        proto.RoleName = ms.ReadUTF8String();

        if (isChild)
        {
            GameEntry.Pool.EnqueueClassObject(ms);
        }
        return(proto);
    }
Ejemplo n.º 2
0
    public byte[] ToArray(MMO_MemoryStream ms, bool isChild = false)
    {
        ms.SetLength(0);
        if (!isChild)
        {
            ms.WriteUShort(ProtoCode);
        }

        ms.WriteInt(RoleType);

        byte[] buff_CurrRole = CurrRole.ToArray(new MMO_MemoryStream(), true);
        ms.WriteInt(buff_CurrRole.Length);
        ms.Write(buff_CurrRole, 0, buff_CurrRole.Length);

        if (RoleList != null)
        {
            int len_RoleList = RoleList.Count;
            ms.WriteInt(len_RoleList);
            for (int i = 0; i < len_RoleList; i++)
            {
                Role_DataProto _Role_DataProto = RoleList[i];
                byte[]         _buff_Curr      = _Role_DataProto.ToArray(new MMO_MemoryStream(), true);
                ms.WriteInt(_buff_Curr.Length);
                ms.Write(_buff_Curr, 0, _buff_Curr.Length);
            }
        }
        else
        {
            ms.WriteInt(0);
        }

        return(ms.ToArray());
    }
Ejemplo n.º 3
0
    public static Role_ListTestProto GetProto(byte[] buffer, bool isChild = false)
    {
        Role_ListTestProto proto = new Role_ListTestProto();

        MMO_MemoryStream ms = null;

        if (!isChild)
        {
            ms = GameEntry.Socket.SocketSendMS;
        }
        else
        {
            ms = GameEntry.Pool.DequeueClassObject <MMO_MemoryStream>();
        }
        ms.SetLength(0);
        ms.Write(buffer, 0, buffer.Length);
        ms.Position = 0;

        proto.RoleType = ms.ReadInt();

        int len_CurrRole = ms.ReadInt();

        if (len_CurrRole > 0)
        {
            byte[] buff_CurrRole = new byte[len_CurrRole];
            ms.Read(buff_CurrRole, 0, len_CurrRole);
            proto.CurrRole = Role_DataProto.GetProto(buff_CurrRole, true);
        }

        int len_RoleList = ms.ReadInt();

        if (len_RoleList > 0)
        {
            proto.RoleList = new List <Role_DataProto>();
            for (int i = 0; i < len_RoleList; i++)
            {
                int _len_RoleList = ms.ReadInt();
                if (_len_RoleList > 0)
                {
                    byte[] _buff_RoleList = new byte[_len_RoleList];
                    ms.Read(_buff_RoleList, 0, _len_RoleList);
                    proto.RoleList.Add(Role_DataProto.GetProto(_buff_RoleList, true));
                }
            }
        }

        if (isChild)
        {
            GameEntry.Pool.EnqueueClassObject(ms);
        }
        return(proto);
    }
Ejemplo n.º 4
0
    public static Role_DataProto GetProto(MMO_MemoryStream ms, byte[] buffer)
    {
        Role_DataProto proto = new Role_DataProto();

        ms.SetLength(0);
        ms.Write(buffer, 0, buffer.Length);
        ms.Position = 0;

        proto.RoleId   = ms.ReadInt();
        proto.RoleName = ms.ReadUTF8String();

        return(proto);
    }
Ejemplo n.º 5
0
    public byte[] ToArray(bool isChild = false)
    {
        MMO_MemoryStream ms = null;

        if (!isChild)
        {
            ms = GameEntry.Socket.SocketSendMS;
            ms.SetLength(0);
            ms.WriteUShort(ProtoCode);
        }
        else
        {
            ms = GameEntry.Pool.DequeueClassObject <MMO_MemoryStream>();
            ms.SetLength(0);
        }

        ms.WriteInt(RoleType);

        byte[] buff_CurrRole = CurrRole.ToArray(true);
        ms.WriteInt(buff_CurrRole.Length);
        ms.Write(buff_CurrRole, 0, buff_CurrRole.Length);

        if (RoleList != null)
        {
            int len_RoleList = RoleList.Count;
            ms.WriteInt(len_RoleList);
            for (int i = 0; i < len_RoleList; i++)
            {
                Role_DataProto _Role_DataProto = RoleList[i];
                byte[]         _buff_Curr      = _Role_DataProto.ToArray(true);
                ms.WriteInt(_buff_Curr.Length);
                ms.Write(_buff_Curr, 0, _buff_Curr.Length);
            }
        }
        else
        {
            ms.WriteInt(0);
        }

        byte[] retBuffer = ms.ToArray();
        if (isChild)
        {
            GameEntry.Pool.EnqueueClassObject(ms);
        }
        return(retBuffer);
    }
Ejemplo n.º 6
0
    public static Role_ListTestProto GetProto(MMO_MemoryStream ms, byte[] buffer)
    {
        Role_ListTestProto proto = new Role_ListTestProto();

        ms.SetLength(0);
        ms.Write(buffer, 0, buffer.Length);
        ms.Position = 0;

        proto.RoleType = ms.ReadInt();

        int len_CurrRole = ms.ReadInt();

        if (len_CurrRole > 0)
        {
            byte[] buff_CurrRole = new byte[len_CurrRole];
            ms.Read(buff_CurrRole, 0, len_CurrRole);
            proto.CurrRole = Role_DataProto.GetProto(new MMO_MemoryStream(), buff_CurrRole);
        }

        int len_RoleList = ms.ReadInt();

        if (len_RoleList > 0)
        {
            proto.RoleList = new List <Role_DataProto>();
            for (int i = 0; i < len_RoleList; i++)
            {
                int _len_RoleList = ms.ReadInt();
                if (_len_RoleList > 0)
                {
                    byte[] _buff_RoleList = new byte[_len_RoleList];
                    ms.Read(_buff_RoleList, 0, _len_RoleList);
                    proto.RoleList.Add(Role_DataProto.GetProto(new MMO_MemoryStream(), _buff_RoleList));
                }
            }
        }

        return(proto);
    }