void updateFriendUI()
    {
        pageGO.GetComponent <SpriteText>().Text = (page + 1).ToString();
        Relation relation    = CDataPool.Instance.GetRelation();
        int      friendCount = relation.GetListCount(RELATION_GROUP.RELATION_GROUP_F1);

        for (int i = 0; i < itemCount; ++i)
        {
            int iFriend = i + page * itemCount;
            SDATA_RELATION_MEMBER friend  = relation.GetRelationInfo(RELATION_GROUP.RELATION_GROUP_F1, iFriend);
            GameObject            nameGo  = getChildGO(item[i], "name");
            GameObject            levelGo = getChildGO(item[i], "level");
            if (iFriend < friendCount)
            {
                nameGo.GetComponent <SpriteText>().Text  = friend.m_szName;
                levelGo.GetComponent <SpriteText>().Text = friend.m_nLevel.ToString();
                if (!item[i].active)
                {
                    item[i].SetActiveRecursively(true);
                }
            }
            else
            {
                item[i].SetActiveRecursively(false);
            }
        }
        friendNumber.Text = "好友数量 " + friendCount.ToString();
    }
    // 从服务器端接收一个黑名单玩家
    public bool                                                             AddRelation(_BLACKNAME_INFO pBlackName)
    {
        RelationList pRelationList;

        pRelationList = GetRelationList(RELATION_GROUP.RELATION_GROUP_BLACK);
        if (pRelationList == null)
        {
            return(false);
        }

        SDATA_RELATION_MEMBER pNewRelation;

        pNewRelation = pRelationList.GetMemberByGUID(pBlackName.m_GUID);

        if (pNewRelation != null)
        {
            pNewRelation.m_szName       = UIString.Instance.GetUnicodeString(pBlackName.m_szTargetName);
            pNewRelation.m_RelationType = RELATION_TYPE.RELATION_TYPE_BLACKNAME;
            return(true);
        }
        else
        {
            pNewRelation = new SDATA_RELATION_MEMBER();

            if (pNewRelation == null)
            {
                return(false);
            }

            pNewRelation.m_GUID         = pBlackName.m_GUID;
            pNewRelation.m_szName       = UIString.Instance.GetUnicodeString(pBlackName.m_szTargetName);
            pNewRelation.m_RelationType = RELATION_TYPE.RELATION_TYPE_BLACKNAME;
            return(pRelationList.Add(pNewRelation));
        }
    }
    // 加入名单
    public override bool                                           Add(SDATA_RELATION_MEMBER pMember)
    {
        if (m_vecRelationMember.Count < 1)
        {     // 初始化最大 Order
            m_nMaxOrder = 0;
        }

        while (m_vecRelationMember.Count >= SDATA_RELATION_MEMBER.LIST_MEMBER_COUNT)
        {     // 人数太多
            int nSize;

            nSize = m_vecRelationMember.Count;
            for (int i = 0; i < nSize; ++i)
            {
                if (m_vecRelationMember[i].m_nEnterOrder == 1)
                {
                    m_vecRelationMember.RemoveAt(i);
                    --m_nMaxOrder;
                }
                else
                {
                    --(m_vecRelationMember[i].m_nEnterOrder);
                }
            }
        }

        pMember.m_nEnterOrder = ++m_nMaxOrder;     // 所以最小 Order 为 1

        return(base.Add(pMember));
    }
 // 判断是否名单需要的类型
 protected override bool                                           IsFitType(SDATA_RELATION_MEMBER pMember)
 {
     return((pMember.m_RelationType == RELATION_TYPE.RELATION_TYPE_FRIEND) ||
            (pMember.m_RelationType == RELATION_TYPE.RELATION_TYPE_BROTHER) ||
            (pMember.m_RelationType == RELATION_TYPE.RELATION_TYPE_MARRY) ||
            (pMember.m_RelationType == RELATION_TYPE.RELATION_TYPE_MASTER) ||
            (pMember.m_RelationType == RELATION_TYPE.RELATION_TYPE_PRENTICE));
 }
    // 根据关系类型或者友好度确定双方关系,并存入 m_szRelation
    protected bool                                                 SetRelationDesc(SDATA_RELATION_MEMBER pMember)
    {
        switch (pMember.m_RelationType)
        {
        case RELATION_TYPE.RELATION_TYPE_FRIEND:                                                //好友
        {
            if (pMember.m_nFriendPoint < 10)
            {
                pMember.m_szRelation = "一面之缘";
            }
            else if (pMember.m_nFriendPoint <= 200)
            {
                pMember.m_szRelation = "泛泛之交";
            }
            else if (pMember.m_nFriendPoint <= 500)
            {
                pMember.m_szRelation = "君子之交";
            }
            else if (pMember.m_nFriendPoint <= 1000)
            {
                pMember.m_szRelation = "莫逆之交";
            }
            else if (pMember.m_nFriendPoint > 1000)
            {
                pMember.m_szRelation = "刎颈之交";
            }
            else
            {
                pMember.m_szRelation = "普通朋友";
            }
        }
        break;

        case RELATION_TYPE.RELATION_TYPE_BROTHER:                                               //结拜
            pMember.m_szRelation = "金兰之好";
            break;

        case RELATION_TYPE.RELATION_TYPE_MARRY:                                                 //结婚
            pMember.m_szRelation = "夫妻";
            break;

        case RELATION_TYPE.RELATION_TYPE_BLACKNAME:                                     //黑名单
            pMember.m_szRelation = "交恶";
            break;

        case RELATION_TYPE.RELATION_TYPE_TEMPFRIEND:                                            //临时好友
            pMember.m_szRelation = "临时好友";
            break;

        //	case RELATION_TYPE_MASTER:						//师傅关系
        //	case RELATION_TYPE_PRENTICE:					//徒弟关系
        default:
            return(false);
        }

        return(true);
    }
    void chat(int index)
    {
        Relation relation    = CDataPool.Instance.GetRelation();
        int      friendCount = relation.GetListCount(RELATION_GROUP.RELATION_GROUP_F1);

        if (index < friendCount)
        {
            SDATA_RELATION_MEMBER friend = relation.GetRelationInfo(RELATION_GROUP.RELATION_GROUP_F1, index);
            Talk.Instance.TargetName = friend.m_szName;
            Talk.Instance.SetChatType(ENUM_CHAT_TYPE.CHAT_TYPE_TELL);
        }
    }
    // 根据队伍人数设置组队显示数据,并存入 m_szTeamDesc
    protected bool                                                 SetTeamDesc(SDATA_RELATION_MEMBER pMember)
    {
        if (pMember.m_nTeamSize == 0)
        {
            pMember.m_szTeamDesc = "未组队";
        }
        else
        {
            pMember.m_szTeamDesc = "已组队" + pMember.m_nTeamSize + "人";
        }

        return(true);
    }
    public bool                                                             AddRelation(_FRIEND_INFO pFriend)
    {
        RelationList pRelationList;

        switch ((RELATION_GROUP)pFriend.m_uGroup)
        {
        case RELATION_GROUP.RELATION_GROUP_F1:
        case RELATION_GROUP.RELATION_GROUP_F2:
        case RELATION_GROUP.RELATION_GROUP_F3:
        case RELATION_GROUP.RELATION_GROUP_F4:
            pRelationList = GetRelationList((RELATION_GROUP)pFriend.m_uGroup);
            break;

        default:
            return(false);
        }

        if (pRelationList == null)
        {
            return(false);
        }

        SDATA_RELATION_MEMBER pNewRelation;

        pNewRelation = pRelationList.GetMemberByGUID(pFriend.m_GUID);

        if (pNewRelation != null)
        {
            pNewRelation.m_szName       = UIString.Instance.GetUnicodeString(pFriend.m_szTargetName);
            pNewRelation.m_RelationType = (RELATION_TYPE)pFriend.m_uRelationType;
            pNewRelation.m_nFriendPoint = pFriend.m_nFriendpoint;
            return(true);
        }
        else
        {
            pNewRelation = new SDATA_RELATION_MEMBER();

            pNewRelation.m_GUID         = pFriend.m_GUID;
            pNewRelation.m_szName       = UIString.Instance.GetUnicodeString(pFriend.m_szTargetName);
            pNewRelation.m_RelationType = (RELATION_TYPE)pFriend.m_uRelationType;
            pNewRelation.m_nFriendPoint = pFriend.m_nFriendpoint;
            return(pRelationList.Add(pNewRelation));
        }
    }
    // 加入名单
    public virtual bool                                             Add(SDATA_RELATION_MEMBER pMember)
    {
        bool bAddedFlag = false;

        if (m_vecRelationMember.Count >= SDATA_RELATION_MEMBER.LIST_MEMBER_COUNT)
        {     // 人数太多
            return(false);
        }

        if (!IsFitType(pMember))
        {     // 不应该放到这类名单里
            return(false);
        }

        for (int i = 0; i < (int)m_vecRelationMember.Count; ++i)
        {     // 按拼音顺序插入现有名单
            int nRet;

            nRet = Compare(pMember, m_vecRelationMember[i]);
            if (nRet < 0)
            {         // 优先级低
                continue;
            }
            else
            {
                m_vecRelationMember.Insert(i, pMember);
                bAddedFlag = true;
                break;
            }
        }

        if (!bAddedFlag)
        {
            m_vecRelationMember.Add(pMember);
        }

        return(true);
    }
        public void delFriend(RELATION_GROUP group, int index) //删除一个好友
        {
            SDATA_RELATION_MEMBER pInfo = CDataPool.Instance.GetRelation().GetRelationInfo(group, index);

            if (group == RELATION_GROUP.RELATION_GROUP_TEMPFRIEND)      // 如果是临时好友
            {
                CDataPool.Instance.GetRelation().RemoveRelation(group, index);
                GameProcedure.s_pEventSystem.PushEvent(GAME_EVENT_ID.GE_UPDATE_FRIEND);
                return;
            }
            else if (group == RELATION_GROUP.RELATION_GROUP_BLACK)
            {
                CGRelation Msg = new CGRelation();

                Msg.GetRelation().CleanUp();
                Msg.GetRelation().m_Type = (byte)RELATION_REQUEST_TYPE.REQ_DELFROMBLACKLIST;

                RELATION_GUID pBlackName    = new RELATION_GUID();
                Msg.GetRelation().mRelation = pBlackName;
                pBlackName.CleanUp();
                pBlackName.SetTargetGUID(pInfo.m_GUID);
                NetManager.GetNetManager().SendPacket(Msg);
            }
            else
            {
                CGRelation Msg = new CGRelation();
                Msg.GetRelation().CleanUp();
                Msg.GetRelation().m_Type    = (byte)RELATION_REQUEST_TYPE.REQ_DELFRIEND;
                REQUEST_DEL_FRIEND pFriend  = new REQUEST_DEL_FRIEND();
                Msg.GetRelation().mRelation = pFriend;
                pFriend.CleanUp();
                pFriend.SetTargetGUID(pInfo.m_GUID);
                NetManager.GetNetManager().SendPacket(Msg);
            }

            return;
        }
        //加入好友功能(包括好友、临时好友、黑名单)
        public void addFriend(RELATION_GROUP nGroup, string name)
        {
            string            strva    = name;
            CGRelation        Msg      = new CGRelation();
            CObject_Character pCharObj = null;

            Msg.GetRelation().m_Type = (byte)RELATION_REQUEST_TYPE.REQ_ADDFRIEND;
            REQUEST_ADD_RELATION_WITH_GROUP pFriend = new REQUEST_ADD_RELATION_WITH_GROUP();

            Msg.GetRelation().mRelation = pFriend;
            pFriend.CleanUp();

            bool valueIsNum = false;                                /*Ogre::StringConverter::isNumber(strva.c_str());*/

            if (nGroup == RELATION_GROUP.RELATION_GROUP_FRIEND_ALL) // 如果直接一个名字,就自动往所有的列表里加,
            {
                nGroup = RELATION_GROUP.RELATION_GROUP_F1;
            }
            else if (nGroup == RELATION_GROUP.RELATION_GROUP_TEMPFRIEND) //临时好友
            {
                SDATA_RELATION_MEMBER pMember = new SDATA_RELATION_MEMBER();

                if (!valueIsNum)
                {
                    pCharObj = (CObject_Character)CObjectManager.Instance.FindCharacterByName(strva);
                    if (pCharObj == null)
                    {
                        return;
                    }
                    pMember.m_szName = strva;
                }
                else
                {
                    pCharObj = (CObject_Character)CObjectManager.Instance.GetMainTarget();
                    if (pCharObj == null)
                    {
                        return;
                    }
                    pMember.m_szName = pCharObj.GetCharacterData().Get_Name();
                }
                // 如果是玩家并且是统一阵营的才会添加
                ENUM_RELATION sCamp = Interface.GameInterface.Instance.GetCampType(pCharObj, CObjectManager.Instance.getPlayerMySelf());
                if ((pCharObj is CObject_PlayerOther) == false)
                {
                    return;
                }
                if (sCamp != ENUM_RELATION.RELATION_FRIEND)
                {
                    return;
                }

                int nTmpGroup = -1, nIndex = -1;
                CDataPool.Instance.GetRelation().GetRelationByName(pMember.m_szName, ref nTmpGroup, ref nIndex);
                if (nTmpGroup >= 0)
                {
                    return;
                }

                pMember.m_RelationType = RELATION_TYPE.RELATION_TYPE_TEMPFRIEND;
                if (CDataPool.Instance.GetRelation().AddRelation(RELATION_GROUP.RELATION_GROUP_TEMPFRIEND, pMember))
                {
                    string szText = "你将" + pMember.m_szName + " 添加为临时好友";
                    GameProcedure.s_pEventSystem.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, szText);
                }
                CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_UPDATE_FRIEND);
                return;
            }
            else if (nGroup == RELATION_GROUP.RELATION_GROUP_BLACK)
            { // 增加黑名单的添加
                CGRelation Msg1                 = new CGRelation();
                Msg1.GetRelation().m_Type       = (byte)RELATION_REQUEST_TYPE.REQ_ADDTOBLACKLIST;
                REQUEST_ADD_RELATION pBlackName = new REQUEST_ADD_RELATION();
                Msg1.GetRelation().mRelation    = pBlackName;
                pBlackName.CleanUp();

                if (strva == "")
                {
                    pCharObj = (CObject_Character)CObjectManager.Instance.GetMainTarget();
                    if (pCharObj == null)
                    {
                        return;
                    }
                    pBlackName.SetTargetName(EncodeUtility.Instance.GetGbBytes(pCharObj.GetCharacterData().Get_Name()));
                }
                else if (valueIsNum)
                {
//                      pCharObj = (CObject_Character)CObjectManager.Instance.FindCharacterByRaceID(int.Parse(strva));
//                      if( pCharObj == null ) pCharObj = (CObject_Character*)CObjectManager::GetMe()->FindCharacterByName(strva.c_str());
//                      if( pCharObj == null ) return ;
//                      pBlackName->SetTargetGUID( Ogre::StringConverter::parseInt(strva.c_str()) );
                }
                else
                {
                    pCharObj = (CObject_Character)CObjectManager.Instance.FindCharacterByName(strva);
                    if (pCharObj == null)
                    {
                        return;
                    }
                    pBlackName.SetTargetName(EncodeUtility.Instance.GetGbBytes(strva));
                }

                if (pCharObj == CObjectManager.Instance.getPlayerMySelf())
                {
                    return;
                }

                if (pCharObj is CObject_PlayerOther)        // 如果是玩家
                {
                    ENUM_RELATION sCamp = Interface.GameInterface.Instance.GetCampType(pCharObj, CObjectManager.Instance.getPlayerMySelf());
                    if (sCamp != ENUM_RELATION.RELATION_FRIEND)
                    {
                        GameProcedure.s_pEventSystem.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "不能添加不同阵营的人到黑名单");
                        return;
                    }
                }
                else
                {
                    GameProcedure.s_pEventSystem.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "不能添加非玩家到黑名单");
                    return;
                }

                pBlackName.SetRelationType((byte)RELATION_TYPE.RELATION_TYPE_BLACKNAME);
                NetManager.GetNetManager().SendPacket(Msg1);
                return;
            }

            if (strva == "")
            {
                pCharObj = (CObject_Character)CObjectManager.Instance.GetMainTarget();
                if (pCharObj == null)
                {
                    return;
                }
                pFriend.SetTargetName(EncodeUtility.Instance.GetGbBytes(pCharObj.GetCharacterData().Get_Name()));
            }
            else if (valueIsNum)
            {
//              pCharObj = (CObject_Character)CObjectManager::GetMe()->FindCharacterByRaceID(Ogre::StringConverter::parseInt(strva.c_str()));
//              if( pCharObj == NULL ) pCharObj = (CObject_Character*)CObjectManager::GetMe()->FindCharacterByName(strva.c_str());
//              if( pCharObj == NULL ) return 0;
//              pFriend->SetTargetGUID( Ogre::StringConverter::parseInt(strva.c_str()) );
            }
            else
            {
                pFriend.SetTargetName(EncodeUtility.Instance.GetGbBytes(strva));
                pCharObj = (CObject_Character)CObjectManager.Instance.FindCharacterByName(strva);
                if (pCharObj == null)
                {
                    return;
                }
            }
            if (pCharObj == CObjectManager.Instance.getPlayerMySelf())      // 如果是自己,就不加
            {
                return;
            }

            if (pCharObj is CObject_PlayerOther)       // 如果是玩家
            {
                ENUM_RELATION sCamp = Interface.GameInterface.Instance.GetCampType(pCharObj, CObjectManager.Instance.getPlayerMySelf());
                if (sCamp != ENUM_RELATION.RELATION_FRIEND)             // 如果不是同一阵营的
                {
                    GameProcedure.s_pEventSystem.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "不能添加不同阵营的人到好友");
                    return;
                }
//              // 改为势力判断 [9/26/2011 Ivan edit]
//              if (pCharObj.GetCharacterData().GetShiLi() !=
//                  CObjectManager::GetMe()->GetMySelf()->GetCharacterData()->GetShiLi())
//              {
//                  CGameProcedure::s_pEventSystem->PushEvent( GE_INFO_SELF, "不能添加不同势力的人到好友" );
//                  return 0;
//              }
            }
            else
            {
                GameProcedure.s_pEventSystem.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "不能添加非玩家到好友");
                return;
            }

            pFriend.SetGroup((byte)nGroup);
            pFriend.SetRelationType((byte)RELATION_TYPE.RELATION_TYPE_FRIEND);

            NetManager.GetNetManager().SendPacket(Msg);

            return;
        }
    // 加入一个关系,用于游戏过程中,加入时需要指定将要加入的组
    public bool                                                             AddRelation(RELATION_GROUP RelationGroup, SDATA_RELATION_MEMBER pMember)
    {
        RelationList pRelationList;

        pRelationList = GetRelationList(RelationGroup);
        if (pRelationList == null)
        {
            return(false);
        }

        // 不让重复加好友,不能加自己为好友
        if (pMember.m_GUID != MacroDefine.UINT_MAX)
        {
            if (CObjectManager.Instance.getPlayerMySelf().GetServerGUID() == pMember.m_GUID)
            {
                return(false);
            }

            RELATION_GROUP rg  = RELATION_GROUP.RELATION_GROUP_F4;
            int            idx = 0;

            if (GetRelationPosition(pMember.m_GUID, ref rg, ref idx) != RELATION_TYPE.RELATION_TYPE_STRANGER)
            {
                return(false);
            }
            else if (pRelationList.GetMemberByGUID(pMember.m_GUID) != null)
            {
                return(false);
            }
        }
        else if (pMember.m_szName.Length > 0)
        {
            string str1 = CObjectManager.Instance.getPlayerMySelf().GetCharacterData().Get_Name();
            string str2 = pMember.m_szName;
            if (str1 == str2)
            {
                return(false);
            }

            int nrg = 0;
            int idx = 0;

            if (GetRelationByName(pMember.m_szName, ref nrg, ref idx) != RELATION_TYPE.RELATION_TYPE_STRANGER)
            {
                return(false);
            }
            else if (pRelationList.GetMemberByName(pMember.m_szName) != null)
            {
                return(false);
            }
        }

        SDATA_RELATION_MEMBER pNewRelation = new SDATA_RELATION_MEMBER();

        pNewRelation.m_GUID         = pMember.m_GUID;
        pNewRelation.m_szName       = (pMember.m_szName);
        pNewRelation.m_RelationType = pMember.m_RelationType;
        pNewRelation.m_nFriendPoint = pMember.m_nFriendPoint;
        pNewRelation.m_nLevel       = pMember.m_nLevel;
        pNewRelation.m_nMenPai      = pMember.m_nMenPai;
        pNewRelation.m_nPortrait    = pMember.m_nPortrait;
        pNewRelation.m_GuildID      = pMember.m_GuildID;
        pNewRelation.m_szGuildName  = (pMember.m_szGuildName);
        pNewRelation.m_bOnlineFlag  = pMember.m_bOnlineFlag;
        SetRelationDesc(pNewRelation);

        if (pMember.m_bOnlineFlag)
        {
            pNewRelation.m_szMood  = pMember.m_szMood;
            pNewRelation.m_szTitle = pMember.m_szTitle;
            pNewRelation.m_SceneID = pMember.m_SceneID;
            GetLocationName(pNewRelation.m_SceneID, out pNewRelation.m_szLocation);
            pNewRelation.m_nTeamSize = pMember.m_nTeamSize;
            SetTeamDesc(pNewRelation);
        }
        else
        {
            pNewRelation.m_szLocation = "离线";
        }

        pRelationList.Add(pNewRelation);
        UpdateUIList(RelationGroup);

        return(true);
    }
        public override NET_RESULT_DEFINE.PACKET_EXE Execute(PacketBase pPacket, ref Peer pPlayer)
        {
            if (GameProcedure.GetActiveProcedure() == (GameProcedure)GameProcedure.s_ProcMain)
            {
                GCRelation packet = (GCRelation)pPacket;
                if (GameProcedure.s_pUISystem == null)
                {
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
                }

                GC_RELATION pReturn = packet.GetRelation();
                string      szText  = "其他好友操作。";

                Relation pRelation = CDataPool.Instance.GetRelation();
                if (pRelation == null)
                {
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
                }

                switch ((RELATION_RETURN_TYPE )pReturn.m_Type)
                {
                case RELATION_RETURN_TYPE.RET_RELATIONLIST:
                {
                    GC_RELATIONLIST pRelationList = (GC_RELATIONLIST)pReturn.mRelation;

                    pRelation.SetMood(UIString.Instance.GetUnicodeString(pRelationList.GetMood()));

                    for (int i = 0; i < pRelationList.GetFriendCount(); ++i)
                    {
                        pRelation.AddRelation(pRelationList.GetFriend(i));
                    }

                    for (int i = 0; i < pRelationList.GetBlackCount(); ++i)
                    {
                        pRelation.AddRelation(pRelationList.GetBlackName(i));
                    }

                    // 需要 push 一个事件通知 UI
                    pRelation.UpdateUIList(RELATION_GROUP.RELATION_GROUP_FRIEND_ALL);
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
                }
                break;

                case RELATION_RETURN_TYPE.RET_RELATIONINFO:
                {
                    pRelation.UpdateRelationInfo((RETURN_RELATION_INFO )pReturn.mRelation);
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
                }
                break;

                case RELATION_RETURN_TYPE.RET_TEMPFRIEND_TO_FRIEND:
                case RELATION_RETURN_TYPE.RET_TEMPFRIEND_ADDTO_BLACKLIST:
                case RELATION_RETURN_TYPE.RET_ADDFRIEND:
                case RELATION_RETURN_TYPE.RET_ADDTOBLACKLIST:
                {
                    RETURN_ADD_RELATION pAddRelation = (RETURN_ADD_RELATION)pReturn.mRelation;
                    RELATION_GROUP      Drg;
                    string msg = UIString.Instance.GetUnicodeString(pAddRelation.GetRelationData().GetName());
                    if (pAddRelation.GetRelationType() == (byte)RELATION_TYPE.RELATION_TYPE_BLACKNAME)
                    {
                        szText = "你将" + msg + "加入黑名单。";
                        //			    strTemp = NOCOLORMSGFUNC("GCRelationHandler_Info_Add_Black_List", pAddRelation.GetRelationData().GetName());
                        //			    _snprintf(szText, _MAX_PATH, "%s", strTemp.c_str());
                        Drg = RELATION_GROUP.RELATION_GROUP_BLACK;
                    }
                    else if (pAddRelation.GetRelationType() == (byte)RELATION_TYPE.RELATION_TYPE_FRIEND)
                    {
                        szText = "你将" + msg + "添加为好友。";
                        //			    strTemp = NOCOLORMSGFUNC("GCRelationHandler_Info_Add_Firend_List", pAddRelation.GetRelationData().GetName());
                        //			    _snprintf(szText, _MAX_PATH, "%s", strTemp.c_str());
                        Drg = (RELATION_GROUP)pAddRelation.GetGroup();
                    }
                    else
                    {
                        szText = "意外的关系类型:" + pAddRelation.GetRelationType();
                        //				    strTemp = NOCOLORMSGFUNC("GCRelationHandler_Info_Err_Relation", pAddRelation.GetRelationData().GetName());
                        //				    _snprintf(szText, _MAX_PATH, "%s", strTemp.c_str());
                        //				    AssertEx(FALSE, szText);
                        return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
                    }

                    _RELATION pRelationData;
                    pRelationData = pAddRelation.GetRelationData();

                    // 如果是临时好友,则移除
                    pRelation.RemoveRelation(pRelationData.GetGUID());
                    pRelation.RemoveRelation(RELATION_GROUP.RELATION_GROUP_TEMPFRIEND, UIString.Instance.GetUnicodeString(pRelationData.GetName()));

                    SDATA_RELATION_MEMBER Member = new SDATA_RELATION_MEMBER();

                    Member.m_GUID         = pRelationData.GetGUID();
                    Member.m_szName       = UIString.Instance.GetUnicodeString(pRelationData.GetName());
                    Member.m_RelationType = (RELATION_TYPE)pAddRelation.GetRelationType();
                    Member.m_nLevel       = pRelationData.GetLevel();
                    Member.m_nMenPai      = pRelationData.GetMenPai();
                    Member.m_nPortrait    = pRelationData.GetPortrait();
                    Member.m_GuildID      = pRelationData.GetGuildID();
                    Member.m_szGuildName  = UIString.Instance.GetUnicodeString(pRelationData.GetGuildName());
                    Member.m_bOnlineFlag  = pRelationData.GetOnlineFlag() != 0;

                    if (Member.m_bOnlineFlag)
                    {
                        Member.m_szMood    = UIString.Instance.GetUnicodeString(pRelationData.GetMood());
                        Member.m_szTitle   = UIString.Instance.GetUnicodeString(pRelationData.GetTitle());
                        Member.m_SceneID   = pRelationData.GetSceneID();
                        Member.m_nTeamSize = pRelationData.GetTeamSize();
                    }

                    pRelation.AddRelation(Drg, Member);

                    // 更新好友信息 [9/26/2011 Ivan edit]
                    CObject_Character player = (CObject_Character)(CObjectManager.Instance.FindCharacterByName(Member.m_szName));
                    if (player != null)
                    {
                        player.GetCharacterData().RefreshName();
                    }
                }
                break;

                case RELATION_RETURN_TYPE.RET_TRANSITION:
                {
//                  RETURN_ADD_RELATION pAddRelation = (RETURN_ADD_RELATION)(pReturn.mRelation);
//                  RELATION_GROUP Drg;
//
//                  // 将好友分组到黑名单才提示 [6/23/2011 edit by ZL]
//                  if ( pAddRelation.GetRelationType() == (byte)RELATION_TYPE_BLACKNAME )
//                  {
//                      string name = UIString.Instance.GetUnicodeString(pAddRelation.GetRelationData().GetName());
//                         szText = "你将"+name+"加入黑名单";
//                      Drg = (RELATION_GROUP)RELATION_GROUP_BLACK;
//                      GameProcedure.s_pEventSystem.PushEvent( GAME_EVENT_ID.GE_INFO_SELF, szText );
//                  }

                    RELATION_GUID_UCHAR_UCHAR pRelationInfo = (RELATION_GUID_UCHAR_UCHAR)(pReturn.mRelation);

                    RELATION_GROUP Srg = RELATION_GROUP.RELATION_GROUP_FRIEND_ALL;
                    int            idx = 0;

                    pRelation.GetRelationPosition(pRelationInfo.GetTargetGUID(), ref Srg, ref idx);
                    pRelation.MoveRelation(Srg, (RELATION_TYPE)pRelationInfo.GetRelationType(),
                                           (RELATION_GROUP)pRelationInfo.GetGroup(), pRelationInfo.GetTargetGUID());

                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);;
                }
                break;

                case RELATION_RETURN_TYPE.RET_DELFRIEND:
                case RELATION_RETURN_TYPE.RET_DELFROMBLACKLIST:
                {
                    pRelation.RemoveRelation(((RELATION_GUID)pReturn.mRelation).GetTargetGUID());
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
                }
                break;

                case RELATION_RETURN_TYPE.RET_ADDFRIENDNOTIFY:
                {
                    //				_snprintf(szText, _MAX_PATH, "%s已经将你添加为好友了。", pReturn.m_NotifyFriend.GetName() );
//                  ADDTALKMSG(szText);
//                                      strTemp = NOCOLORMSGFUNC("GCRelationHandler_Info_Add_You_To_Firend_List", pReturn.m_NotifyFriend.GetName());
//                                      _snprintf(szText, _MAX_PATH, "%s", strTemp.c_str());
//                                      CGameProcedure::s_pEventSystem.PushEvent( GE_INFO_SELF, szText );
//                                      // 询问是否加对方为好友 [6/22/2011 edit by ZL]
//                                      CGameProcedure::s_pEventSystem.PushEvent( GE_FRIEND_MSG_CONFIRM, "201", pReturn.m_NotifyFriend.GetName(), pReturn.m_NotifyFriend.GetGUID() );
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);;
                }
                break;

                case RELATION_RETURN_TYPE.RET_ONLINELIST:
                {
                    RETURN_ONLINE_LIST pRecv = (RETURN_ONLINE_LIST)(pReturn.mRelation);

                    for (byte i = 0; i < pRecv.GetOnlineCount(); ++i)
                    {
                        pRelation.UpdateOnlineFriend(pRecv.GetOnlineRelation(i));
                    }

                    //CObjectManager::GetMe().GetMySelf().GetCharacterData().Get_IsMinorPwdSetup(TRUE);

                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);;
                }
                break;

                case RELATION_RETURN_TYPE.RET_RELATIONONLINE:
                {
                    RETURN_NOTIFY_ONLINE pRecv = (RETURN_NOTIFY_ONLINE)(pReturn.mRelation);
                    pRelation.RelationOnline(UIString.Instance.GetUnicodeString(pRecv.GetTargetName()), UIString.Instance.GetUnicodeString(pRecv.GetMood()));
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
                }
                break;

                case RELATION_RETURN_TYPE.RET_RELATIONOFFLINE:
                {
                    pRelation.RelationOffLine(((RELATION_GUID )pReturn.mRelation).GetTargetGUID());
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);;
                }
                break;

                case RELATION_RETURN_TYPE.RET_NEWMOOD:
                {
                    REQUEST_MODIFY_MOOD mood = (REQUEST_MODIFY_MOOD)pReturn.mRelation;
                    pRelation.SetMood((UIString.Instance.GetUnicodeString(mood.GetMood())));
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);;
                }
                break;

                case RELATION_RETURN_TYPE.RET_ERR_PASSWDMISMATCH:
                {
                    CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_MINORPASSWORD_OPEN_UNLOCK_PASSWORD_DLG);
                }
                break;

                case RELATION_RETURN_TYPE.RET_ERR_TARGETNOTEXIST:
                case RELATION_RETURN_TYPE.RET_ERR_GROUPISFULL:
                case RELATION_RETURN_TYPE.RET_ERR_ISFRIEND:
                case RELATION_RETURN_TYPE.RET_ERR_ISBLACKNAME:
                case RELATION_RETURN_TYPE.RET_ERR_CANNOTTRANSITION:
                case RELATION_RETURN_TYPE.RET_ERR_ISNOTFRIEND:
                case RELATION_RETURN_TYPE.RET_ERR_ISNOTINBLACKLIST:
                case RELATION_RETURN_TYPE.RET_ERR_SPOUSETOBLACKLIST:
                case RELATION_RETURN_TYPE.RET_ERR_MASTERTOBLACKLIST:
                case RELATION_RETURN_TYPE.RET_ERR_PRENTICETOBLACKLIST:
                case RELATION_RETURN_TYPE.RET_ERR_BROTHERTOBLACKLIST:
                case RELATION_RETURN_TYPE.RET_ERR_DELSPOUSE:
                case RELATION_RETURN_TYPE.RET_ERR_DELMASTER:
                case RELATION_RETURN_TYPE.RET_ERR_DELPRENTICE:
                case RELATION_RETURN_TYPE.RET_ERR_DELBROTHER:
                case RELATION_RETURN_TYPE.RET_ERR_CANNOT_ADDFRIEND:
                case RELATION_RETURN_TYPE.RET_ERR_CANNOTRECEIVEMAIL:
                case RELATION_RETURN_TYPE.RET_ERR_NOTRECVSTRANGEMAIL:
                case RELATION_RETURN_TYPE.RET_ERR_RELATIONUNKNOWN:
                {
//                  STRING strTemp = "";
//                  strTemp = NOCOLORMSGFUNC(pRelationString[ pReturn.m_Type - RET_ERR_START ]);
//                  strncpy(szText, strTemp.c_str(), MAX_PATH-1);
//                  //strncpy(szText, pRelationString[ pReturn.m_Type - RET_ERR_START ], MAX_PATH-1);
                    szText = "错误";
                }
                break;

                case RELATION_RETURN_TYPE.RET_ERR_ISENEMY:
                {
                    szText = "阵营错误";
                }
                break;

                default:
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);;
                }

                GameProcedure.s_pEventSystem.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, szText);
            }

            return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);;
        }
 // 判断是否名单需要的类型
 protected virtual bool                                          IsFitType(SDATA_RELATION_MEMBER pMember)
 {
     return(false);
 }
 // 判断是否名单需要的类型
 protected override bool                                           IsFitType(SDATA_RELATION_MEMBER pMember)
 {
     return(pMember.m_RelationType == RELATION_TYPE.RELATION_TYPE_TEMPFRIEND);
 }
 // 比较两个关系人的优先排放顺序(<0表示优先级低,0表示相等,>0表示优先级高)
 protected virtual int                                                   Compare(SDATA_RELATION_MEMBER pMember1, SDATA_RELATION_MEMBER pMember2)
 {
     return(CompareByName(pMember1.m_szName, pMember2.m_szName));
 }
    // 比较两个关系人的优先排放顺序(<0表示优先级低,0表示相等,>0表示优先级高)
    protected override int                                                    Compare(SDATA_RELATION_MEMBER pMember1, SDATA_RELATION_MEMBER pMember2)
    {
        int nPriority1;
        int nPriority2;

        nPriority1 = CalcPriority(pMember1);
        nPriority2 = CalcPriority(pMember2);

        if (nPriority1 > nPriority2)
        {
            return(1);
        }
        else if (nPriority1 < nPriority2)
        {
            return(-1);
        }
        else
        {
            return(base.Compare(pMember1, pMember2));
        }
    }
 // 计算一个好友的优先级,用于排序,目前仅用于 Compare 使用,所以返回值不定义
 protected int                                                                     CalcPriority(SDATA_RELATION_MEMBER pMember)
 {
     if (pMember.m_RelationType == RELATION_TYPE.RELATION_TYPE_MARRY)
     {
         return(10);
     }
     else if (pMember.m_RelationType == RELATION_TYPE.RELATION_TYPE_BROTHER)
     {
         return(9);
     }
     else if (pMember.m_nFriendPoint >= GAMEDEFINE.FRIEND_POINT_ENOUGH_NOTIFY)
     {     // 亲密好友
         if (pMember.m_bOnlineFlag)
         { // 如果在线
             return(8);
         }
         else
         {
             return(7);
         }
     }
     else
     {
         return(6);
     }
 }