Exemple #1
0
    public void UpdateField(int Id, int Index, byte[] buff, int start, int len)
    {
        SyncIdE SyncId = (SyncIdE)Id;

        byte[] updateBuffer = new byte[len];
        Array.Copy(buff, start, updateBuffer, 0, len);
        int  iValue = 0;
        long lValue = 0;

        switch (SyncId)
        {
        case SyncIdE.FRIENDLIST:
            if (Index < 0)
            {
                m_Instance.ClearFriendList(); break;
            }
            if (Index >= m_Instance.SizeFriendList())
            {
                int Count = Index - m_Instance.SizeFriendList() + 1;
                for (int i = 0; i < Count; i++)
                {
                    m_Instance.AddFriendList(new FriendFriendObjWraperV1());
                }
            }
            m_Instance.GetFriendList(Index).FromMemoryStream(new MemoryStream(updateBuffer));
            break;

        case SyncIdE.BLACKLIST:
            if (Index < 0)
            {
                m_Instance.ClearBlackList(); break;
            }
            if (Index >= m_Instance.SizeBlackList())
            {
                int Count = Index - m_Instance.SizeBlackList() + 1;
                for (int i = 0; i < Count; i++)
                {
                    m_Instance.AddBlackList(new FriendFriendObjWraperV1());
                }
            }
            m_Instance.GetBlackList(Index).FromMemoryStream(new MemoryStream(updateBuffer));
            break;

        case SyncIdE.CONTACTSLIST:
            if (Index < 0)
            {
                m_Instance.ClearContactsList(); break;
            }
            if (Index >= m_Instance.SizeContactsList())
            {
                int Count = Index - m_Instance.SizeContactsList() + 1;
                for (int i = 0; i < Count; i++)
                {
                    m_Instance.AddContactsList(new FriendFriendObjWraperV1());
                }
            }
            m_Instance.GetContactsList(Index).FromMemoryStream(new MemoryStream(updateBuffer));
            break;

        case SyncIdE.STRANGERFRIENDLIST:
            if (Index < 0)
            {
                m_Instance.ClearStrangerFriendList(); break;
            }
            if (Index >= m_Instance.SizeStrangerFriendList())
            {
                int Count = Index - m_Instance.SizeStrangerFriendList() + 1;
                for (int i = 0; i < Count; i++)
                {
                    m_Instance.AddStrangerFriendList(-1);
                }
            }
            GameAssist.ReadInt64Variant(updateBuffer, 0, out lValue);
            m_Instance.SetStrangerFriendList(Index, lValue);
            break;

        default:
            break;
        }

        try
        {
            if (NotifySyncValueChanged != null)
            {
                NotifySyncValueChanged(Id, Index);
            }
        }
        catch
        {
            Ex.Logger.Log("FriendData.NotifySyncValueChanged catch exception");
        }
        updateBuffer.GetType();
        iValue++;
        lValue++;
    }